Page 1 of 2

[Solved] Problem with AnAL - Animation speeded-up

Posted: Tue Jul 14, 2015 3:19 pm
by NowakFul
Hello guys!
I have a problem with AnAL lib, when I insert one enemy, the animation is normal for the enemy but when I insert more than one enemy the animation of walking is speeded-up.

Video : https://www.youtube.com/watch?v=e_K8kyNhcJs

Thank you in advance, if you need more information to help me ask me, and sorry for my bad english :)

Re: Problem with AnAL - Animation speeded-up

Posted: Tue Jul 14, 2015 5:39 pm
by bartbes
You're probably updating the same animation twice.

Re: Problem with AnAL - Animation speeded-up

Posted: Tue Jul 14, 2015 5:45 pm
by NowakFul
bartbes wrote:You're probably updating the same animation twice.
Thanks for the answer, but the only update that I have in my code is here :

Code: Select all

if self.walking == "true" and self.direction == "left" then
	walking_left_bomber:update(dt)
	self.x = self.x - self.speed
end
if self.walking == "true" and self.direction == "right" then
	walking_right_bomber:update(dt)
	self.x = self.x + self.speed
end
if self.walking == "false" and self.direction == "right" then
	dont_walking_right_bomber:update(dt)
end
if self.walking == "false" and self.direction == "left" then
	dont_walking_left_bomber:update(dt)
end

Re: Problem with AnAL - Animation speeded-up

Posted: Tue Jul 14, 2015 7:23 pm
by bartbes
Yes, so what happens if walking_left_bomber and walking_right_bomber are the same? We can't diagnose this properly if you don't share the code.

Re: Problem with AnAL - Animation speeded-up

Posted: Tue Jul 14, 2015 8:13 pm
by NowakFul
bartbes wrote:Yes, so what happens if walking_left_bomber and walking_right_bomber are the same? We can't diagnose this properly if you don't share the code.
So..


LOAD

Code: Select all

	mobObj.walkright_bomber   = love.graphics.newImage('image/MOB/bomber_right.png')
	mobObj.walkright_bomber:setFilter( "nearest", "nearest" )
	mobObj.walkleft_bomber   = love.graphics.newImage('image/MOB/bomber_left.png')
	mobObj.walkleft_bomber:setFilter( "nearest", "nearest" )
	mobObj.dontwalkright_bomber   = love.graphics.newImage('image/MOB/bomber_right_nomove.png')
	mobObj.dontwalkright_bomber:setFilter( "nearest", "nearest" )
	mobObj.dontwalkleft_bomber   = love.graphics.newImage('image/MOB/bomber_left_nomove.png')
	mobObj.dontwalkleft_bomber:setFilter( "nearest", "nearest" )

	walking_right_bomber = newAnimation(mobObj.walkright_bomber, 6, 9, 0.10, 0)
	walking_left_bomber = newAnimation(mobObj.walkleft_bomber, 6, 9, 0.10, 0)
	dont_walking_right_bomber = newAnimation(mobObj.dontwalkright_bomber, 6, 9, 0.50, 0)
	dont_walking_left_bomber = newAnimation(mobObj.dontwalkleft_bomber, 6, 9, 0.50, 0)
UPDATE

Code: Select all

if self.walking == "true" and self.direction == "left" then
	walking_left_bomber:update(dt)
	self.x = self.x - self.speed
end
if self.walking == "true" and self.direction == "right" then
	walking_right_bomber:update(dt)
	self.x = self.x + self.speed
end
if self.walking == "false" and self.direction == "right" then
	dont_walking_right_bomber:update(dt)
end
if self.walking == "false" and self.direction == "left" then
	dont_walking_left_bomber:update(dt)
end
DRAW

Code: Select all

if self.walking == "true" and self.direction == "left" then
	walking_left_bomber:draw(self.x, self.y,0,12) 
end
if self.walking == "true" and self.direction == "right" then
	walking_right_bomber:draw(self.x, self.y,0,12) 
end
if self.walking == "false" and self.direction == "right" then
	dont_walking_right_bomber:draw(self.x, self.y,0,12) 
end
if self.walking == "false" and self.direction == "left" then
		dont_walking_left_bomber:draw(self.x, self.y,0,12) 
end
Maybe you want the entire "mob.lua" file or the .love ?

Re: Problem with AnAL - Animation speeded-up

Posted: Tue Jul 14, 2015 8:18 pm
by davisdude
The .love would be excellent

Re: Problem with AnAL - Animation speeded-up

Posted: Tue Jul 14, 2015 8:28 pm
by NowakFul
davisdude wrote:The .love would be excellent
There it is!

Re: Problem with AnAL - Animation speeded-up

Posted: Tue Jul 14, 2015 8:40 pm
by bartbes
The animations are stored in global variables and shared by the two enemies, so when they both update, the animations get updated twice. You probably want to store the animations on the enemies themselves, or make sure to update the animations only once.

Re: Problem with AnAL - Animation speeded-up

Posted: Tue Jul 14, 2015 9:02 pm
by NowakFul
bartbes wrote: You probably want to store the animations on the enemies themselves, or make sure to update the animations only once.
I've tried things and I've searched on the forums but I doesn't find how I could do this. By which means can I make it? am a bit new to programming sorry. ^^

Re: Problem with AnAL - Animation speeded-up

Posted: Tue Jul 14, 2015 9:15 pm
by bartbes
You're doing it for almost every other variable already, you just have to store it in self (or mobObj), if you do the same with the animations, it should be fixed.