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
var coin:Coin = new Coin("coin", {view:"art.png", touchable:true}); | |
//Within your state class. Same process for Starling or Away3D | |
var coinArt:DisplayObject = view.getArt(coin) as DisplayObject; | |
coinArt.addEventListener(MouseEvent.CLICK, handleCoinClick); | |
private function handleCoinClick(e:MouseEvent):void | |
{ | |
var clickedCoin:Coin = view.getObjectFromArt(e.currentTarget) as Coin; |
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
// Inside a class which extends CitrusObject e.g. CitrusSprite, APhysicsObjects... | |
kill = true; | |
// If you have an access to the variable of the object : | |
hero.kill = true; | |
// Or within a State class (the previous code works too) : | |
remove(hero); |
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
// In a state class : | |
//Here we use Box2D. /!\ Don't forget that your _hero must have its touchable property set to true! | |
var draggableHeroArt:DisplayObject = view.getArt(_hero) as DisplayObject; | |
draggableHeroArt.addEventListener(MouseEvent.MOUSE_DOWN, _handleGrab); | |
stage.addEventListener(MouseEvent.MOUSE_UP, _handleRelease); | |
private function _handleGrab(mEvt:MouseEvent):void { |
NewerOlder