-
-
Save tariqhamid/bcc53d9d6b757c8376d5 to your computer and use it in GitHub Desktop.
EnchantFromAmber touch event handling example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EcGameProgram subclass: #EcTouchEventExample | |
instanceVariableNames: '' | |
package: 'Enchant-Examples'! | |
!EcTouchEventExample methodsFor: 'actions'! | |
prepareBeforeLoad | |
self game assetsBasePath: './game-img/'. | |
self game preloadAssets: #('chara1.png' 'icon0.png'). | |
self game fps: 20. | |
! | |
prepareOnLoad | |
| scene bear | | |
scene := self game rootScene. | |
bear := scene addSprite: (32@32) imageName: 'chara1.png' frame: 5. | |
scene onTouchStart: [:event | | apple | | |
apple := EcSprite extent: 16@16. | |
apple imageName: 'icon0.png'. | |
apple moveTo: (16@ (bear y + 8)). | |
apple tl moveBy: (320@0) time: 30. | |
apple frame: 15. | |
scene add: apple | |
]. | |
scene onTouchMove: [:event | | |
bear y: event localY | |
]. | |
! ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment