CCSprite overlapping each other - cocos2d-iphone

Hi
I am making a cocos2d game, In that i am adding enemies dynamically at different position, and animating them using action.
Enemies are appearing in screen according to the order I added. But I want to show sprites according to its Y value.
Please tell me is there any api in cocos2d to do sorting the sprites according to sprite position, or which is the best way to accomplish this.
Thanks,

Best way to update zOrder based on Y position
Z Order Operations - "Perspective" based games
CCSpriteBatchNode / reorder Z

Related

Tracking 2D coordinates in a 3D space

I am working on a gesture tracking feature for a virtual reality game I am working on. I need to keep track of the players hand coordinates to check them against a existing gesture. I only want to track on the X and Y. My Problem is taking the 3D coordinates and making them 2D. Any suggestions are welcome. Thanks for your time.

Rocket like movement in cocos 2d V3 with chipmunk

On tapping on screen I`m gonna apply impulse and angular rotation to sprite to move it to the sides. But after some time OR parameters of physics body attached to sprite should go back to initial (impulse 0, angular speed = 0). What are the best ways to do that (use CCAction or on update detect parameters of physics body and change them to initial)?
If i were in your position, I would probably start a timer at the first collision of the sprite and then use a CCAction to transition to the initial state to make it look smooth. Don't know if its the best way though.

Cocos2d - hiding, clipping or masking sprite like in game Candy Crush

I have a problem and I saw it also in the game Candy Crush Saga, where they successfully dealt with it. I would like the sprite to show only when it is in the board (see image link below). The board can be of different shapes, like the levels in the mentioned game.
Has anyone some ideas how can this be achieved with Cocos2d?
I will be very glad if someone has some tips.
Thank you in advance.
image link: http://www.android-games.fr/public/Candy-Crush-Saga/candy-crush-saga-bonus.jpg
In Cocos2d you can render sprites at different z levels. Images at a lower z-level will be drawn first by the graphic card and the images (sprites) with a higher z-value will be drawn later. Hence if an image (say A) is at the same position of the other but has a higher z-value you will see only the pixels of image A where the two images intersect.
Cocos2d uses also layers so you can decide to add Sprites to a layer and set the layer to a specific z value. I expect that they used a layer for the board (say at z=1) with a PNG image containing transparent bits in the area where you can see the sprites, and a second layer at z=0 for the sprites. In this way you can only see the sprites when they are in the transparent area.
Does this help?
I found out Cocos2d has a class CCClippingNode which does exatclly what I wanted. First I thought it can clip only rectangular areas, but after some research I found it can clip also paths.

How to stack sprites using collision detection on cocos2d?

I am a beginner on cocos2d an I'm looking for a way to stack 3 sprites one above another in cocos2d. I guess it would require collision detection but I could figure out a way to make it work. Does anybody has any idea that could help me out?
This is a rather vague question without any code examples, but you can simply adjust the position parameters of your CCSprite objects so they are stacked on top of each other. If you used the dimensions of each sprite in your position formula, you can have it automatically know where each sprite is located and position the next one right above it.

How to construct a 3D background by tilting CCSprite around X and/or Y axes using cocos2d-iphone?

I'm trying to create a 3D background with a lava texture. It needs to be tilted around the x axis by 90 degrees to give an illusion of floor. It needs to be able to scroll in any direction infinitely as well.
There is no rotateX or rotateY in CCSprite, and I tried to use CCCamera to achieve a similar effect, but couldn't get it to work the way I wanted either. I also tried CCOrbitCamera, this made the floor rotate constantly which is not desirable.
I also considered writing a subclass of CCSprite, calling CCSprite3D, but don't know what functions to override.
How do I achieve the desired effect?
Please take a look at CameraOrbitTest in cocosnodeTest.