Rotate 2d sprite.png in 3d?

Rotate 2d sprite.png in 3d?
0

Hi, I’d like to rotate a card that has a front and a back.
I thought to have 2 png sprites with different z, add to a node3d and rotate along y axis.
is it possible?
thanks

With this function you will get the position of the camera.

Director::getInstance()->getZEye();

Use wisely to get the point where you change the resource in the middle of a 3d rotation like this ones:

RotateBy::create(middleTime, Vec3(rotation, 0, 0)); // vertical
RotateBy::create(middleTime, Vec3(0, 180-rotation, 0)); // horizontal

You need to use trigonometry to get something like this, the angle where you cant see your resource because is perpendicular to the camera.

x = this->getPositionX();
w = this->getParent()->getContentSize().width / 2;
rotation = 180 + (atan(Director::getInstance()->getZEye()/(w-x))*(180/3.1415926536f));

And then experiment a lot with a breakpoints in the middle of the animation and have fun.

Hope it works.

I’ve tried, but the position of the sprite is in a border of the screen, so, flipping the card, produce not very good effect. can I set the camera for the single sprite so it points the center on the center of the sprite and the eye perpendicular to that sprite?
thanks

It would be nice if you share the javascript equivalent of this. Thanks in advance.