Working with sprites in a 3D world (like on Super Nes)

I’m trying to reproduce my game here in Defold, a “whack a mole” where each pest has a fixed x,y position and a varying z position.
I wonder if it is possible to use sprites with x,y,z position and orientation and an accurate matrix to automaticaly transform world position into the convenient screen-position and scaling.

And I wonder if it’s possible to change a rectangular sprite into a trapezoid one (so each line hasn’t the same x-scaling)

Thanks folks


That would be very easy to do in Defold. I would suggest cutting your trapezoid sprite into four equally sized sections (cut perpendicular to the x axis) then setting the highest up/furthest back one to a Z layer of 0, the middle ones to a Z layer of 0.25, and 0.75 and the lowest down/closest one to 1.

Make the holes in your trapezoid transparent.

Set the z position of the faces to 0.1, 0.26, and 0.76 according to what row they are in.

Should be easy!

Thanks for your reply
I didn’t consider splitting it in four, it’s a good idea

I’m not sure to understand what you mean about holes, do you speak about the black holes for the maules, or the white space around ? Should a black hole of the nearest row be attached (in the scene graphe) to the Z=1.0 or the Z=0.75 trapezoid part ?

And if I had a rectangular sprite and I would like to make it non-rectangular at runtime in Defold (or the inverse : trapezoid non-rectangular to rectangular) would it be possible (with a camera or other stuff) ?

Thanks again

I ping you, to be sure you see my above reply,
Sorry if it bothers you.

@ramoneur the alternative to using sprites is to use model or mesh components to get correct perspective correction. There is some discussion about this here: Perpective behavior incoherence - #4 by Dragosha

1 Like

Delete the black holes. Make them transparent.

You can do this very easily by using a 3D camera and perspective (and indeed with meshes and models, if you want to make things really complicated!), but I would suggest first you try the 2D method with Z-layer adjustment first!

Ok thank you both, I’ll tell you what option I’ll have picked

Let us know if you need any more help and show us the final project!