Anim8- Animation stops and placement

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.
Post Reply
Randalierpirat
Prole
Posts: 7
Joined: Mon Jul 16, 2012 12:49 pm

Anim8- Animation stops and placement

Post by Randalierpirat »

Hello again!
Before I start let me say I really searched for my problem but couldn't seem to find a suitable answer.
So: I have basically 2 problems with anim8 right now
Number 1: the animation stops without going fully through. I realize this is because the trigger event stops. But how do I tell anim8 to do it anyway? Here is my current attempt:

Code: Select all

for i = #vikings, 1, -1 do
 if CheckCollision(Ovie.x, Ovie.y, 48, 96, vikings[i].x,vikings[i].y, 116, 84) == false then
         draw_Ovie()	
else     --	 Ovie.lives = Ovie.lives - 1
                 animation:draw(img, Ovie.x, Ovie.y)		 
                 table.remove(vikings, i)
		end		
This "solution creates another problem, but more on that later.

Number 2: The placement of the animation is also not on the position of my hero(Ovie). I started testing anim8 with a much simpler Spritesheet and since it worked fine in this case , I am a bit flabbergasted. I think it has to do with the picture itself and the fact that it isn't an optimal Spritesheet.( If you know an easy way to make a Spritesheet out of multiple different sized pictures, please tell me)
This monstrosity was made by my girlfriend, so don't be too shocked by the girlishness and overkill of stuff :)


Last but not least I give you my full lovefile for you to look at and criticize.
I know its awful and chaotic with hard coding , possible repetition and stupid placement. But hey its my first try and I will try to tidy up when I get this sucker to work I promise.
Attachments
project.love
I disabled dying in this one and I really need to change the music
(5.02 MiB) Downloaded 119 times
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Anim8- Animation stops and placement

Post by kikito »

Hi there!

1. Animations take some time to "play". In order to "display them normally", it is not enough to create them. You have to create them, and animate them in your love.update loop, just like you are animating the player or the enemies. Consider explosions "another entity" in your game, if that makes things easier.

2. If what I'm seeing is correct, the explosion frames are bigger than the overlord. When you draw an image with love.graphics.draw, you give it a pair of coordinates (x,y). Those coordinates basically mean "draw this image so that its upper-left corner is on these coordinates. Notice that I said "upper left", not "center".

As a result, if you try to use love.graphics.draw to draw two images of different size, they will not appear "centered"; instead, their upper left corners will match. I think that is what is happening in your game.

I see only two options. The easiest one would be modifying your tiles so that all of them had the same size.

The other option would be taking into account the difference in size when drawing each image, and adjusting x and y accordingly, so x and y coincide. These calculations are not terribly complicated, but you will have an easier time with the first option.

I don't know any program to do this automatically, sorry.
When I write def I mean function.
Randalierpirat
Prole
Posts: 7
Joined: Mon Jul 16, 2012 12:49 pm

Re: Anim8- Animation stops and placement

Post by Randalierpirat »

Hi ,
thanks for your answer.
1. So i have to basically make a timer function? No problem.

2. So it is, as expected, the size difference. :(
Resizing isn't really an option for me because it would seem odd seeing the hero shrink and grow.
So how would I calculate the difference? Sadly, math isn't really my strongpoint.
Zeliarden
Party member
Posts: 139
Joined: Tue Feb 28, 2012 4:40 pm

Re: Anim8- Animation stops and placement

Post by Zeliarden »

you can set animation to "once" instead of "loop" and

Code: Select all

 if CheckCollision(Ovie.x, Ovie.y, 48, 96, vikings[i].x,vikings[i].y, 116, 84) == false then
                animation:draw(img, Ovie.x, Ovie.y)
else     --	 Ovie.lives = Ovie.lives - 1
                animation:gotoFrame(1)
		animation:resume()				 
                table.remove(vikings, i)
end	
btw here is a code that shows the collision rectangles

Code: Select all

function CheckCollision(ax1,ay1,aw,ah, bx1,by1,bw,bh)

  local ax2,ay2,bx2,by2 = ax1 + aw, ay1 + ah, bx1 + bw, by1 + bh
  love.graphics.rectangle( "line", ax1,ay1,aw,ah )
  love.graphics.rectangle( "line", bx1,by1,bw,bh )

  return ax1 < bx2 and ax2 > bx1 and ay1 < by2 and ay2 > by1
end
Randalierpirat
Prole
Posts: 7
Joined: Mon Jul 16, 2012 12:49 pm

Re: Anim8- Animation stops and placement

Post by Randalierpirat »

Thank you too.
Edit: Nevermind i got it.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 9 guests