[Solved] Problem with AnAL - Animation speeded-up

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
NowakFul
Prole
Posts: 24
Joined: Mon Jul 28, 2014 7:13 pm

[Solved] Problem with AnAL - Animation speeded-up

Post 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 :)
Last edited by NowakFul on Tue Jul 14, 2015 9:36 pm, edited 1 time in total.
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Problem with AnAL - Animation speeded-up

Post by bartbes »

You're probably updating the same animation twice.
NowakFul
Prole
Posts: 24
Joined: Mon Jul 28, 2014 7:13 pm

Re: Problem with AnAL - Animation speeded-up

Post 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
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Problem with AnAL - Animation speeded-up

Post 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.
NowakFul
Prole
Posts: 24
Joined: Mon Jul 28, 2014 7:13 pm

Re: Problem with AnAL - Animation speeded-up

Post 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 ?
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Problem with AnAL - Animation speeded-up

Post by davisdude »

The .love would be excellent
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
NowakFul
Prole
Posts: 24
Joined: Mon Jul 28, 2014 7:13 pm

Re: Problem with AnAL - Animation speeded-up

Post by NowakFul »

davisdude wrote:The .love would be excellent
There it is!
Attachments
game.love
(27.09 KiB) Downloaded 138 times
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Problem with AnAL - Animation speeded-up

Post 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.
NowakFul
Prole
Posts: 24
Joined: Mon Jul 28, 2014 7:13 pm

Re: Problem with AnAL - Animation speeded-up

Post 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. ^^
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Problem with AnAL - Animation speeded-up

Post 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.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 220 guests