stage:addEventListener(Event.ENTER_FRAME,
function()
Graphic:setRotation(Graphic:getRotation()+ (Timer.delayedCall(math.random(4, 8) ,
function () speed = math.random(1, 30)
return speed
end)
))
end)
Basically, what I am trying to do is, change the speed of rotation randomly, but since I do not want it to change at every second, I tried using Timer.delayedCall in Gideros, but it gives an error that says attempt to perform arithmetic on a table value: Lua error message. How can I fix this?
Comments
http://docs.giderosmobile.com/reference/gideros/Timer/new
there is also the last example project of gideros ide how to use a timer.
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Try This:
local i = 0
local randomRotation = 0
stage:addEventListener(Event.Enter_FRAME,
function()
if i < math.random(4,8) then
i = i +1
else
i = 0
randomRotation = math.random(1,30)
end
Graphic:setRotation(Graphic:getRotation + randomRotation)
end)
Graphic:setRotation(Graphic:getRotation() + randomRotation)