Skip to content

Instantly share code, notes, and snippets.

View alamboley's full-sized avatar

Aymeric Lamboley alamboley

View GitHub Profile
@alamboley
alamboley / gist:4022051
Last active October 12, 2015 11:48
How to handle mouse events (Citrus Engine recipe)
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;
@alamboley
alamboley / gist:4022031
Created November 6, 2012 01:59
How to destroy objects (Citrus Engine recipe)
// 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);
@alamboley
alamboley / gist:4022129
Last active October 12, 2015 11:47
How to grab and drag physics objects (Citrus Engine recipe)
// 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 {