-
The Cheeze to Your Macaroni
Creating layers in AS3
Okay I haven't had to deal with this problem until now...but I was wondering how the hell you can manage entity depth in AS3.
With AS2 I would just set all of my BG objects to a low depth range, and all of my players units and what not at a higher depth range.
With AS3 there doesn't seem to be any way to do this, and I am having big problems with things like my turrets on ships showing up UNDERNEATH them sometimes...its all random things just get placed all over the place.
I'm not really sure how to keep everything where it needs to be. Anybody else know how to solve this issue?
-
Senior Member
The way I'd do it is use separate container sprites for capital ships vs. their turrets. Then composite them into your document class in back to front order:
Code:
public class MainDocument extends Sprite
{
public function MainDocument()
{
var shipsprite : Sprite = new Sprite();
shipsprite.addChild( capitalShip1.sprite );
var turretsprite : Sprite = new Sprite();
for ( t=0; t < capitalShip1.turrets.length; t++ )
turretsprite.addChild( capitalShip1.turrets[t].sprite );
addChild(shipSprite);
addChild(turretSprite);
}
}
-
This post confuses me.
Depth seems like a piece of cake in AS3.
Am I missing something?
addChildAt(), setChildIndex(), swapChildren(), swapChildrenAt()...
If they're all in the same sprite,
ship.parent.setChildIndex(ship,0);
turret.parent.setChildIndex(turret,turret.parent.n umChildren-1);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|