Page 1 of 1
I have a glitch in my game
Posted: Thu Dec 29, 2022 11:38 pm
by MaxGamz
So I want to make a 2 player sports game and I finished creating the code for player 1. I had no issues but when I implemented the code for the second player, I started to get bugs. The animations for the players change depending on the movement of one of the players and the animations are moving way faster for some reason. I checked my code and it seemed to be just fine.
Here is my project
Re: I have a glitch in my game
Posted: Fri Dec 30, 2022 12:36 am
by Xugro
The variable
currentAnim is a global variable that is shared by
player.lua and
polly.lua. Do not use globals for animations, but class fields instead:
Code: Select all
function Polly:animations() -- loads in animations
local g = self.grid
self.idle = anim8.newAnimation(g(("1-4"), 1), 0.1)
self.runAnim = anim8.newAnimation(g(("6-9"), 1), 0.1)
self.jumpAnim = anim8.newAnimation(g((11), 1), 0.1)
self.fallAnim = anim8.newAnimation(g((10), 1), 0.1)
self.currentAnim = self.idle
end
Re: I have a glitch in my game
Posted: Fri Dec 30, 2022 2:35 am
by MaxGamz
Thanks! I didn't think that was the issue. It works perfectly now