Game Development Community

Rotation out-of-plane

by Nikos Beck · in Torque 2D Beginner · 05/28/2014 (6:25 pm) · 3 replies

I'm working on a card game and I want to flip the card. In a 3D engine, I could just rotate it which would deform the shape as a trapezoid to look like the near edge of the card is coming towards the viewer. In T2D, I can't figure out how to do that. Can I render a sprite as a trapezoid rather than a rectangle? Do I paste the sprite onto a 3D shape and then rotate it?

#1
05/29/2014 (4:41 am)
Have you tried scaling the card as it flips to simulate getting closer to the viewer?
#2
05/29/2014 (8:34 am)
I did. It doesn't look right.

I walked through the documentation and there doesn't seem to be a function that can deform a scene object into a trapezoid and looking through the source, it only renders sprites as rectangles.

Thanks for the quick reply Michael.

This morning, I dug into the source and added a 'skew' member to the scene object class and added it as a console method. I can skew the left and right sides of a sprite so that I can draw a trapezoid. It's a hack that only draws a trapezoid without changing collision, physics or mouse functionality which still things the shape is a rectangle.
#3
05/29/2014 (10:44 am)
@Nikos - Nice. Glad you were able to dive into the source and make the changes. I did something similar recently with my "squishy physics" feature. I needed to render a special kind of circle made of wedges that are determined by box2d bodies. It's actually quick and easy to get special rendering injected into T2D. I prefer to call them solutions, rather than hacks.