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.
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
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 |