Skip to content

Instantly share code, notes, and snippets.

@alamboley

alamboley/gist:4565837

Last active Dec 11, 2015
Embed
What would you like to do?
How to manage deeply z-sorting (Citrus Engine recipe)
// In your GameState class extending StarlingState (working for State and Away3DState too).
override public function initialize():void {
super.initialize();
// 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)});
add(cs1);
var cs2:CitrusSprite = new CitrusSprite("cs2", {x:150, y:100, group:5, view:new Quad(100, 100, 0x00FF00)});
add(cs2);
// Each group is a container, each CitrusObject's view is added to the corresponding container.
var container:Sprite = view.getArt(cs1).parent;
// You can also change order into this container!
container.swapChildren(view.getArt(cs1) as StarlingArt, view.getArt(cs2) as StarlingArt);
// We make easily an affect to all children into the group5.
container.filter = new BlurFilter();
// group's container are automatically created when a new group is precised into an object.
// In our case group from 0-5 are created, default object group is 0.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment