Spin a sprite

I want to spin a sprite , I tried the following but it does not seem to do what I expect.

local function rotatehead()
for i = 0, 360, 15 do
instanceHead:rotate(i)
end
end

Any help is greatly appreciated.

you need to understand how the iOS renderer works, you will see the last position.

you need to call the roatation in small increments, it does not work like other *windows* based programming languages, unfortunately...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
local angle = 0
local step =15
local speed = 100
local rotate
 
local instanceHead = display.newRect(10,100,200,50)
 instanceHead:setFillColor(255,0,0)
 
function rotate()
   instanceHead.rotation=angle
   angle = angle+step
 
   if angle<=360 then
    timer.performWithDelay(speed ,rotate)
  end
end
 
timer.performWithDelay(1000,rotate) -- starts after 1 second
views:1503 update:2011/10/11 8:57:46
corona forums © 2003-2011