I have been trying to rotate a sprite but find it hard to get it right. I simplu just want it to rotate while going from top of screen to bottom of the screen. I am guessing that it is because i don’t understand quaternion and go.set_rotation needs one. Is there an simple example how to rotate an sprite without messing with my downward motion of the sprite, in the sprite i have this script:
function init(self)
self.speed = 1000
end
function update(self, dt)
local pos = go.get_position()
pos.y = pos.y - self.speed * dt
go.set_position(pos)
go.set_scale(0.8)
end
Now i have spinning asteroids in my game=) Should i sit down and try to understand quaternions or can i manage without them? Or maybe learn them in a later time?
Really all you need to do is read through the vmath documentation that Mathias linked. There are convenient functions for basically everything you will need to do with quaternions. Also, to add to quaternion rotations together, you multiply them. (kind of like a transformation matrix)
To learn an api, you usually have to go through several times.
Even if you don’t know what everything does exactly, a little more “sticks” with you each time, and with time you’ll start to connect things together in your head.