Arrow Keys to control movement of a Morph
Milan Zimmermann
milan.zimmermann at sympatico.ca
Wed Jul 7 03:05:07 UTC 2004
Alex,
Thanks for the tip .. did not occur to me to look at games, I was trapped it
the "search Google" and "search Squeak Wiki" approach ... Playing with an
eToy approach to this as well using a patch from Karl,
Milan
On July 5, 2004 02:58 am, Alexander Lazarević wrote:
> Hi Milan,
>
> Look at an existing game by loading it with the PackageLoader from
> SqeakMap. Sokoban for example uses the arrow keys to move a morph
> around. There you will find this methods, which should you get started:
>
> *handlesKeyboard: aMorphicEvent
> ^ true
>
> *and
>
> *keyStroke: aKeyboardEvent
>
> | char |
>
> char := aKeyboardEvent keyCharacter.
> char = Character arrowLeft ifTrue: [^ self moveLeft].
> char = Character arrowRight ifTrue: [^ self moveRight].
> char = Character arrowUp ifTrue: [^ self moveUp].
> char = Character arrowDown ifTrue: [^ self moveDown].
> char asLowercase = $a ifTrue: [^ self again].
> * [...]
>
> Alex
More information about the Squeak-dev
mailing list
|