Skip to content

Instantly share code, notes, and snippets.

Aymeric Lamboley alamboley

Block or report user

Report or block alamboley

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
alamboley / gist:4565837
Last active Dec 11, 2015
How to manage deeply z-sorting (Citrus Engine recipe)
View gist:4565837
// In your GameState class extending StarlingState (working for State and Away3DState too).
override public function initialize():void {
// The group property specifies the depth sorting: objects placed in group 1 will be behind objects placed in group 2.
// Here both objects have the same group, therefore the first added will be behind the second.
var cs1:CitrusSprite = new CitrusSprite("cs1", {x:100, y:100, group:5, view:new Quad(100, 100, 0xFF0000)});
alamboley / gist:4060507
Created Nov 12, 2012
How to use the AGameData class (Citrus Engine recipe)
View gist:4060507
// The AGameData class is an abstract (it should be extend) and dynamic class (you won't have problem
// to access its chidren properties, be careful your IDE may not indicate children properties).
public class MyGameData extends AGameData {
public function MyGameData() {
_levels = [[Level1, "levels/A1/LevelA1.swf"], [Level2, "levels/A2/LevelA2.swf"]];
alamboley / gist:4030440
Created Nov 7, 2012
How to change or destroy State (Citrus Engine recipe)
View gist:4030440
// In the Main class :
public function Main() {
state = new TiledMapGameState();
setTimeout(otherState, 4000);
private function otherState():void {
alamboley / gist:4024623
Last active Oct 12, 2015
How to make a preloader (Citrus Engine recipe)
View gist:4024623
// Arts specified by a path to a file like "levels/coin.png" are loaded under the hood by the Citrus Engine.
//You can follow the progression in your GameState :
//add a mask to the game to hide objects loading in the background
_maskDuringLoading = new Quad(stage.stageWidth, stage.stageHeight);
// create a textfield to show the loading %
_percentTF = new TextField(400, 200, "", "ArialMT");
alamboley / gist:4024296
Last active Oct 12, 2015
How to set up a camera (Citrus Engine recipe)
View gist:4024296
// In a GameState, the parameters are the object to follow, the offset, the bounds and the easing., new Point(stage.stageWidth / 2, stage.stageHeight / 2), new Rectangle(0, 0, 1550, 450), new Point(.25, .05));
// You can add more interactivity :
stage.addEventListener(MouseEvent.MOUSE_WHEEL, _mouseWheel);
CitrusEngine.getInstance().input.keyboard.addKeyAction("rotate", Keyboard.X);
private function _mouseWheel(mEvt:MouseEvent):void {
if ( > 0)
alamboley / gist:4024256
Created Nov 6, 2012
How to use the Level Manager (Citrus Engine recipe)
View gist:4024256
//In your Main class :
public function Main() {
levelManager = new LevelManager(ALevel);
levelManager.applicationDomain = ApplicationDomain.currentDomain; // to be able to load your SWF level on iOS
levelManager.levels = [[Level1, "levels/A1/LevelA1.swf"], [Level2, "levels/A2/LevelA2.swf"]];
levelManager.gotoLevel(); //load the first level, you can change the index. You can also call it later.
alamboley / gist:4024068
Last active Oct 12, 2015
How to play sounds (Citrus Engine recipe)
View gist:4024068
// In the Main class, register the sounds :
sound.addSound("Hurt", {sound:"sounds/hurt.mp3"});
sound.addSound("Collect", {sound:"sounds/collect.mp3"});
sound.addSound("Song", {sound:"sounds/song.mp3",timesToPlay:-1});
// In your GameState play them when needed :
private function handleHeroTakeDamage():void {
alamboley / gist:4024051
Created Nov 6, 2012
How to add commands to the console (Citrus Engine recipe)
View gist:4024051
//In the Main class add this command. It will pause and unpause the game :
this.console.addCommand("pause", pauseGame);
private function pauseGame():void {
this.playing = !this.playing;
//Using parameters :
this.console.addCommand("goto", goto);
alamboley / gist:4022129
Last active Oct 12, 2015
How to grab and drag physics objects (Citrus Engine recipe)
View gist:4022129
// 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 {
alamboley / gist:4022074
Created Nov 6, 2012
How to specify the view (Citrus Engine recipe)
View gist:4022074
// If you want to use Blitting view instead of the SpriteView override this method in your State class :
//Make sure and call this override to specify Blitting mode.
override protected function createView():CitrusView {
return new BlittingView(this);
//Using Starling or Away3D you don't need to override the view since it uses StarlingState/Away3D which already specify StarlingView/Away3DView.
//Don't forget that your Main class should extend StarlingCitrusEngine or Away3DCitrusEngine.
You can’t perform that action at this time.