Skip to content

Instantly share code, notes, and snippets.

@tariqhamid
Forked from mumez/EcTouchEventExample.st
Created February 25, 2016 10:23
Show Gist options
  • Save tariqhamid/bcc53d9d6b757c8376d5 to your computer and use it in GitHub Desktop.
Save tariqhamid/bcc53d9d6b757c8376d5 to your computer and use it in GitHub Desktop.
EnchantFromAmber touch event handling example
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