Skip to content

Instantly share code, notes, and snippets.

Last active December 11, 2015 07:19
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save alamboley/4565837 to your computer and use it in GitHub Desktop.
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 {
// 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)});
var cs2:CitrusSprite = new CitrusSprite("cs2", {x:150, y:100, group:5, view:new Quad(100, 100, 0x00FF00)});
// 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