Hi!
I’m trying to move an object from left and to the right and I’m gonna build 3 “lanes” in which the object can move but in my early code I’m getting an error and not sure why, I’m using the code from the movieclip tutorial. The error I’m getting is:
“Syntax error: /Users/carolineback/Desktop/Micke/Kodningar/main.lua:51: unexpected symbol near ‘[’”
And this is my code:
-- Initialize a second cube anim (this time by creating the image table dynamically)
imageTable = {}
for i = 1,4 do
table.insert( imageTable, "whale\_pre" .. i .. ".png" )
end
-- Create myAnim2 object
myAnim2 = movieclip.newAnim( imageTable )
foreground:insert( myAnim2 )
-- Add some frame labels (optional)
myAnim2:setLabels{left=3, right=4}
-- Position myAnim2
myAnim2.x = 50
myAnim2.y = 300
local actions["button1"] = function()
myAnim2:play{ startFrame=3, endFrame=3, loop=1, remove=true }
transition.to(myAnim2, { time=2000, y=myAnim2.y+100, x=myAnim2.x+100 } )
end
actions["button2"] = function()
myAnim2:play{ startFrame=4, endFrame=4, loop=1, remove=true }
transition.to(myAnim2, { time=2000, y=myAnim2.y-100, x=myAnim2.x-100 } )
end
myAnim2 consists of 4 png-files. 1 and 2 are the default animation and 3 is the character turning to the left, and 4 is the character turning to the right.
Any idea how this error could be avoided? Or do you even have a better programming solution to my animation?
Thank you [import]uid: 21652 topic_id: 5440 reply_id: 305440[/import]