Page 1 of 1

Trouble with my animator

Posted: Sun Jan 10, 2016 5:36 am
by ZBoyer1000
I had an idea to create a platformer game and I started with animating a character.
The code itself works fine for 1 character, but when there is more than 1 of them, only one of them gets rendered.
Is there any way to get around this issue without causing any problems?
P.s The id thing I put into the functions don't actually work or cause much problems, I normally use them as notes or as a label to keep things organized. However, I would have a use for it if I figured out how I could use it. :monocle:

https://www.mediafire.com/?q2iqppa2b2tqjpj

Re: Trouble with my animator

Posted: Sun Jan 10, 2016 4:11 pm
by ZBoyer1000
Here, me. I have your problem fixed and the link above now contains the updated version which can handle more than 1 entity at one time. Also, the code is good for people having trouble creating character animations with tables or something related. :3

I wondering if it's possible to simplify making the pitch of music change. The only problem is that I might not get to that point for another 2 or 3 months based on how distracted I am all the time. :monocle:

Re: Trouble with my animator

Posted: Sun Jan 10, 2016 4:25 pm
by CaptainMaelstrom
See my attached .love.

Whenever you use a function like

Code: Select all

variable:functionname(arg1, arg2)

end
It's basically the same as saying:

Code: Select all

variable.functionname(variable, arg1, arg2)

end
Where, to reference variable inside the body of the function, you can use the "self" keyword:

Code: Select all

player = {}
function player:new(arg1, arg2)
   self.timer = arg1
end

player:new(0)
The above creates a table called "player" and then gives it a variable "timer". So that "player.timer" is set to 0. If I were to then add

Code: Select all

player2 = {}
player2:new(1)
This would create a second player, with "player2.timer" equal to 1.

Re: Trouble with my animator

Posted: Thu Jan 14, 2016 3:53 am
by ZBoyer1000
Thanks! These segments of code could help me in the future. :ultrahappy: