# Using CCFlipY3D to flip cards one on top of another

Using CCFlipY3D to flip cards one on top of another
0.0 0

#1

Hi everyone,

I’m trying to use CCFlipX3D to simulate a flipping card game.
In the game, there are a few cards stacked on top of the other, and once the user touches a point,
they move from that point, and some of them flip.

The problem is that if I use CCFlipX3D for this effect, the flipping cards “goes into” cards below it.
Is there a way to prevent this?

I’ve tried settings the depth of the cards to be different, but this still happens, even if the z order is spaced by more than 1 unit (say 100, 200, 300 etc… for each card).
Any idea how can I fix this?
Also, is there a way to make the back of a card NOT be the mirror image of it but a different sprite?

Right now I’m using a scale effect (scale X to 0, change sprite frame, then back to 1) to simulate a flip, however the 3D effects will be much nicer to use.

Any idea what is wrong?

Thanks,
Idan

#2

Hi, perfer VertexZ than ZOrder.
Suppose the Size of up Sprite is 40 * 40.
In order to see all the up Sprite during the Flip,
you must assure that the VertexZ of the up Sprite is at least
20 larger than all sprite below it.

#3

Hi, thanks!

It seems to be working, except that changing the z vertex changes my sprites sizes (since they are now nearer to the camera…)
What is the easiest way to make them not scale?

Should I change the projection matrix? and if so how?

Thanks,
Idan

#4

In my opinion, the easiest way is Calculating the ScaleFactor after VertexZ set,
than Scale the sprites.But you may need to adjust the Sprite’s position.
I calculate these in this way:

suppose orign position Pos, orign vertexZ is 0, and the new vertexZ is Vz, new position is NewPos;

HalfForv = 30;
ZScreen = ScreenSize.height * 0.5f / tan(HalfForv);
ScaleFactor = (ZScreen - Vz) / ZScreen;
NewPos.x = (Pos.x - ScreenSize.width * 0.5f) * ScaleFactor + ScreenSize.width * 0.5f;
NewPos.y = (Pox.y - ScreenSize.height * 0.5f) * ScaleFactor + ScreenSize.height * 0.5f;