Fellow coders!
I’m new to coding, learning everything bit by bit and copy & pasting but I can’t get the below code to work.
Hope you can understand the problem with these snippets:
– I create the Levels here. One of the parameters is the name of the animation “PlayerStanding”
object[1] = CreateObject (WIDTH/2, HEIGHT/2, WIDTH/25, HEIGHT/10, “player”,“PlayerStanding”,4)
– This is my animation with table of images and animation speed:
PlayerStanding = Animation ({“Dropbox:PlayerStanding”},12)
– and here is where my problem arises:
CreateObject = class()
function CreateObject:init(x,y,w,h,Category,AnimationName,ASpeed)
– Parameters are given to self
self.AnimationName = AnimationName – this is for the parameter “PlayerStanding” of above
function CreateObject:draw()
– finally this is giving an error “attempt to call a nil value”
self.AnimationName:draw(self.body.x, self.body.y, self.w)
Apologies for torturing you with snippets only but the code is so beginnerishly organised and terribly long in full.
It seems I did not grasp the calling of classes yet.
Printing self.AnimationName is giving PlayerStanding. So it’s not nil.
PlayerStanding:draw(self.body.x,…) works. But how do I call it with a variable so I can process all my objects with different animations?
Thanks so much for your patience!