sprite isn’t a table, though, it’s a function. I suppose it could be a table or a class, with the normal
sprite function as its
_call, but it feels odd to me. Maybe using
local i = readImage(img, angle) or
local i = readImage(img) i.angle = *angle*? I have wanted width and height parameters to
I think my favorite is
I think all this becomes quite compicated, while
is really clear, compact and fine. Isnt it?
So we come full circle I like the way it currently works. Its flexible enough to support a range of individual ordered transforms, sometimes you will want to order them in different ways other than rotating the sprite first. Understanding this (even for noobs) is pretty important.
@Jmv38 it is clear, compact and fine once you have a bit of programming experience under your belt. So I am with you 100% and I too like the current way that it works.
However, for a novice I would argue it’s pretty complex. As someone starting out, I want to plonk a sprite on the screen. Great there is a command for that. When I type it, a window appears which lets me pick the image I want to put on the screen. I need to tell the function where to put it on the screen? OK so I need to give it an x and y position. Simple enough. Plus there’s options to change the size - great.
Now I want to rotate the sprite - a fairly common thing to do when you are starting out. So, I can’t simply tell the sprite function how much to rotate the sprite? So, first I need to start with the pushMatrix() command and finish with the popMatrix() command. What is the purpose of these commands? Seems complex, but lets just accept them for the moment. Now what’s this translate command? That’s where I put the x and y position of the sprite. I thought that was set in the sprite() command? No, the sprite command should now contain the coordinates of the bottom left of the screen and the translate command will hold the x and y position and move the sprite from the bottom left to the desired position. OK. Next there is the rotate command - the command that actual rotates the sprite. Just enter the amount of rotation into the function. One more thing to note. The order of these commands matters, and the order they are executed starts from the bottom and works up (place the sprite in the bottom left, rotate it then move it to the desired position), which for someone starting out might seem counterintuitive. Changing the order of rotate and translate will give you a different result.
I understand the advantages of the existing method, but I certainly found it confusing when I was starting out and am pretty sure other people do. So while I find it clear, compact and fine, I can also see why it is unclear, unnecessarily long and not fine for a beginner. Having said this, I can’t offer a solution which keeps the existing advanced users happy as well as making it as easy as possible for beginners. I think @dave1707’s suggestion for a global current rotation which any subsequent sprite call inherits is about the best so far.
Unless rotate becomes a property of an image, rather than a parameter of sprite, this is consistent with setRect! which has a rotation parameter