I’m using CCSprite to redraw my app’s background image (it’s like a moving background). However I’m also using CCSprite to draw my hero and enemies. At some cases the enemies goes behind my background image. My understanding is that if you do:
[self addChild:sprite1];
[self addChild:sprite2];
Then sprite1 will be behind sprite2 if they intersect each other in the window. However is there any way to bring sprite1 back to front in case they intersect sprite2? I tried looking at the documentation but cocos2d doesn’t seem to have the method that I’m looking…
I have not used cocos2d…
In general If you want to bring sprite1 on the top of sprite2
similarly If you want to bring sprite2 on the top of sprite1
You need to implement replaceChild method… Usually addChild method adds element to an array, You can use replaceObjectAtIndex method if it is array.