Reputation: 2606
I'm trying to create ncar table with 2 different functions: setup ans main_frame
local ncar=
{
img=display.newImageRect("test_car.png",50,120,true);
x=0;
y=0;
frames=0;
setup=function(self)
return self;
end
main_frame=function(self)
self.frames=self.frames+1;
return function(event)
self.img.x=self.x;
self.img.y=self.y;
end
end
}
But compiler says that he expects to see '}' where the second function (main_frame in this case) starts, when I add it. What are the reasons?
Upvotes: 0
Views: 435
Reputation: 23737
A comma or semicolon is required after setup
function definition.
This is because you are creating a table by listing its fields, that should be separated from each other.
Upvotes: 3