How to handle mouse events (Citrus Engine recipe)
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; | |
if (clickedCoin) | |
{ | |
//do your logic here | |
clickedCoin.kill = true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment