Hello, I have this code
GameScene = gideros.class(Sprite)
function GameScene:init()
Timer.delayedCall(15,self.test,{param1 ="p1", param2 = "p2"})
end
function GameScene:test(args)
print(args.param1)
print(args.param2)
end
when I run it I have an error "attempt to index local 'args' (a nil value)".
but when I change it like follows it works
GameScene = gideros.class(Sprite)
function GameScene:init()
Timer.delayedCall(15,test,{param1 ="p1", param2 = "p2"})
end
function test (args)
print(args.param1)
print(args.param2)
end
any suggestion??
Comments
if you define method through colon (:), it means it accepts first argument as self automatically.
So you can do stuff like that:
So the correct way to handle this situation would be either like this: