I am working on 2D card game. I wanted to simulate perspective view for the cards.
To do this it seems I have to scale down from the top edge and scale up from bottom edge.
I think correct term for what i wanted to do is; convert rectangle to trapezoid
The node can be skewed but does not offer any feature to do something like this.
I’ve been able to fake a flip 90 degrees by using this code:
var animationTime = 0.1;
var rotateByAction = cc.rotateBy(animationTime, 0 , 90);
var rotationSequence = cc.sequence(rotateByAction);
this.node.runAction(rotateSequence);
This rotates a card on its Y-axis 90 degrees to the point where the card disappears from the screen. The tricky part is the other half of the flip, which is what I am currently working on.
So far, the best approach would be to reverse the action with a new Sprite which would be the back card image.
If by perspective view you mean a 3D View on a 2D surface? The Cocos Creator API will let you rotate nodes on the X and Y Axis. For this type of perspective view it might be worthwhile to look into OpenGL vectors to achieve something. You’ll want to use cc.director in order to control the scene in which your game takes place.
To get a better understanding of how the Cocos2Dx framework operates here are some helpful images.
Objects are placed on the screen using nodes. You can manipulate cc.Node to scale, skew, and rotate in a scene.