Hi,
I am trying my hand on framebased animation. When I use this code It executes but also gives me an error telling me I attempt to set property (rotation) with nil.
Thing is it happens at a different frame every time I run it. Also there is a small stutter in the anim.
Here is the code:
local Qsquare=display.newRect(100,100,50,100)
local function QSquare(event)
if event.phase == "began" then
local rotater={}
rotater[01]={}
rotater[02]={}
rotater[03]={}
rotater[04]={}
rotater[05]={}
rotater[06]={}
rotater[07]={}
rotater[08]={}
rotater[09]={}
rotater[10]={}
rotater[11]={}
rotater[12]={}
rotater[13]={}
rotater[14]={}
rotater[15]={}
rotater[16]={}
rotater[17]={}
rotater[18]={}
rotater[19]={}
rotater[20]={}
rotater[21]={}
rotater[22]={}
rotater[23]={}
rotater[24]={}
rotater[25]={}
rotater[01].rotate=1
rotater[02].rotate=3
rotater[03].rotate=5
rotater[04].rotate=7
rotater[06].rotate=9
rotater[07].rotate=11
rotater[08].rotate=13
rotater[09].rotate=15
rotater[10].rotate=17
rotater[11].rotate=19
rotater[12].rotate=21
rotater[13].rotate=21
rotater[14].rotate=19
rotater[15].rotate=17
rotater[16].rotate=15
rotater[17].rotate=13
rotater[18].rotate=11
rotater[19].rotate=9
rotater[20].rotate=7
rotater[21].rotate=5
rotater[22].rotate=3
rotater[23].rotate=2
rotater[24].rotate=1
rotater[25].rotate=0
local animate
local posCount = 0
local function rotateObject()
print(posCount)
if posCount \<= 25 then
Qsquare.rotation = rotater[posCount].rotate
posCount = posCount + 1
else
posCount=1
timer.cancel(animate)
end
end
local function rotateAnim()
posCount = 1
animate = timer.performWithDelay( 1, rotateObject, #rotater )
end
rotateAnim()
end
return true
end
Qsquare:addEventListener("touch",QSquare)
I am using rotation in this example cause it quicker than plotting out a path for position. I have no clue what i am doing wrong.
Any help is greatly appreciated. [import]uid: 100901 topic_id: 28492 reply_id: 328492[/import]