This example shows how a game object is rotated in discrete steps, matching the graphics of the progress spinner.
spinner.script
function init(self)
self.t = 0
self.speed = 16
end
function update(self, dt)
self.t = self.t + dt
local step = math.floor(self.t * self.speed)
local angle = math.pi / 6 * step
local rot = vmath.quat_rotation_z(-angle)
go.set_rotation(rot)
end
self
).update()
.angle
rotation around the Z axis.If you want to play with these examples, you can get the project on Github.
Do you want to see more examples? Why not write a few yourself and submit a pull request? We love contributions.