hmm...
it doesn't rotate, it uses a lot of frames of which (I haven't gone over the script, but I'm assuming) it selects the frame to display based on a calculation of where the mouse cursor is on the screen.
-- Interface
comp_interface = getObject("Interfaces[Kompass]")
-- Lokale Interface-Koordinaten des Kompassnadel-Drehpunktes
rot_point = {55;85}
-- Anzahl Sprites
num_sprites = 64
-- Geschwindigkeit (1=sofort; je größer, je langsamer)
rot_speed = 5
---------------------------------------
-- Aktuelle Position des Kompasses
pos_compass = {0;0}
-- Aktueller Winkel
curr_angle = 0
--Dreht die Kompassnadel in Richtung des Mauszeigers
function spinNeedle()
local pos_cursor = getCursorPos()
local target_angle = math.atan2(pos_compass[2] - pos_cursor.y, pos_compass[1] - pos_cursor.x) / math.pi * 180
local rot_angle = target_angle - curr_angle
if rot_angle <= -180 then
rot_angle = 360 + rot_angle
elseif rot_angle > 180 then
rot_angle = 360 - rot_angle
end
curr_angle = curr_angle + rot_angle / rot_speed
if curr_angle < 0 then
curr_angle = 360 + curr_angle
elseif curr_angle >= 360 then
curr_angle = curr_angle - 360
end
local call_frame = math.floor(curr_angle / 360 * num_sprites + 0.5) + 1
if call_frame == 65 then call_frame = 1 end
comp_anim:setValue(VAnimationFirstFrame, call_frame)
comp_anim:setValue(VAnimationLastFrame, call_frame)
end
-- Speichert die Position des Kompass-Drehpunktes in einer globalen Variable
function setRotationPoint()
local int_pos = comp_interface:getPoint(VInterfacePosition)
pos_compass = {int_pos.x + rot_point[1];int_pos.y + rot_point[2]}
end
P.S: we need something like this:
http://love2d.org/wiki/love.graphics.rotatemind you there's loads of useful sounding stuff listed for the framework! check out all the stuff just for graphics:
http://love2d.org/wiki/love.graphics