Trouble with my animator

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
ZBoyer1000
Prole
Posts: 39
Joined: Sat Nov 28, 2015 10:13 am

Trouble with my animator

Post 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
ZBoyer1000
Prole
Posts: 39
Joined: Sat Nov 28, 2015 10:13 am

Re: Trouble with my animator

Post 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:
User avatar
CaptainMaelstrom
Party member
Posts: 161
Joined: Sat Jan 05, 2013 10:38 pm

Re: Trouble with my animator

Post 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.
Attachments
Experiment.love
(2.26 KiB) Downloaded 93 times
ZBoyer1000
Prole
Posts: 39
Joined: Sat Nov 28, 2015 10:13 am

Re: Trouble with my animator

Post by ZBoyer1000 »

Thanks! These segments of code could help me in the future. :ultrahappy:
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 233 guests