Hi! I'm wondering what the correct approach is to this: I have a AtlasSpriteManager that I now simply add AtlasSprites to and it works just fine. But I have the need to make the AtlasSprites more dynamic. In this particular case I have enemyShips that can a shield around them. Can I subclass AtlasSprite and add both the enemy body and the shield as seperate layers and then add the twolayered AtlasSprite to the AtlasSpriteManager? Or should I have Two AtlasSpriteManagers? One for each layer?
AtlasSprite, manager
(2 posts) (2 voices)-
Posted 2 years ago #
-
The only possible child that can be added to an
AtlasSpriteManageris anAtlasSprite.
And theAtlasSpritecan't have any children.What you can do is to add the shield as a child of the same AtlasSpriteManager.
And you should also schedule a timer, and in that timer you should update the shield position/scale/rotation. eg:-(void) step:(ccTime)dt { id shield = [spriteMgr getChildByTag:kTagShield]; id sprite = [spriteMgr getChildByTag:kTagSprite]; [shield setPosition: [sprite position]]; [shield setScale: [sprite scale]]; [shield setRotation: [sprite rotation]]; }Posted 2 years ago #
Reply
You must log in to post.