need help with anim8

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
tomshreds
Party member
Posts: 101
Joined: Thu Oct 18, 2012 8:49 pm

need help with anim8

Post by tomshreds »

Hi!

I'm using anim8 for my animations, it's a perfect solution and I love it.

But I encountered a little problem. I'm trying to draw OVER an animation but since the animation seems to be redrawn quicker than what I draw after it... or I simply don't why but the anim8 animation gets drawn over what I draw after it programatically-wise.

For example:

self.animation:draw(self.image, x, y)
love.graphics.rectangle('fill', x, y, 300, 200)

The animation gets over the rectangle which seems illogical. Any ideas why?

Thanks!
Last edited by tomshreds on Tue Feb 19, 2013 4:33 am, edited 1 time in total.
scutheotaku
Party member
Posts: 235
Joined: Sat Dec 15, 2012 6:54 am

Re: need help with anim8

Post by scutheotaku »

What are those last two arguments in your love.graphics.rectangle call for? Unless I'm missing something, the docs ( https://www.love2d.org/wiki/love.graphics.rectangle ) only show that function having 5 arguments: draw mode, x, y, width, and height. Perhaps that has something do with it?

If not that...does anim8 possibly change the draw alpha or draw color? Maybe try "resetting" those (e.g. "love.graphics.setColor( 255, 255, 255, 255)" ) between drawing the animation and the rectangle? This seems like a stretch, but I guess it's worth a try...?

EDIT:
And to clarify...are you not seeing the rectangle at all, or is it drawing underneath the animation but you can see part of it (either through transparent parts of the animation's image, or overlapping)?
User avatar
master both
Party member
Posts: 262
Joined: Tue Nov 08, 2011 12:39 am
Location: Chile

Re: need help with anim8

Post by master both »

I bet, it is overlapping. Try to draw the background first and then the player by changing their position on your code.
tomshreds
Party member
Posts: 101
Joined: Thu Oct 18, 2012 8:49 pm

Re: need help with anim8

Post by tomshreds »

scutheotaku wrote:What are those last two arguments in your love.graphics.rectangle call for? Unless I'm missing something, the docs ( https://www.love2d.org/wiki/love.graphics.rectangle ) only show that function having 5 arguments: draw mode, x, y, width, and height. Perhaps that has something do with it?

If not that...does anim8 possibly change the draw alpha or draw color? Maybe try "resetting" those (e.g. "love.graphics.setColor( 255, 255, 255, 255)" ) between drawing the animation and the rectangle? This seems like a stretch, but I guess it's worth a try...?

EDIT:
And to clarify...are you not seeing the rectangle at all, or is it drawing underneath the animation but you can see part of it (either through transparent parts of the animation's image, or overlapping)?
It was a typo when I wrote the example code. Yes we see the rectangle but the animation is over it.

Thanks!
tomshreds
Party member
Posts: 101
Joined: Thu Oct 18, 2012 8:49 pm

Re: need help with anim8

Post by tomshreds »

master both wrote:I bet, it is overlapping. Try to draw the background first and then the player by changing their position on your code.
I don't think so since the draw order is:

- background
- player
- rectangle

:-/ Thanks
tomshreds
Party member
Posts: 101
Joined: Thu Oct 18, 2012 8:49 pm

Re: need help with anim8

Post by tomshreds »

Found the bug. It's because there's multiple instance of the character on the screen. So other character gets drawn over other's bubbles.

Damn.
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: need help with anim8

Post by kikito »

tomshreds wrote:I'm using anim8 for my animations, it's a perfect solution and I love it.
Well, thank you, you are very kind, but it's still not perfect :neko:
tomshreds wrote:Found the bug. It's because there's multiple instance of the character on the screen. So other character gets drawn over other's bubbles.
I'm glad that you found the problem. For the next time, consider uploading a .love file showing the issue, otherwise it's very difficult to know what is happening.
When I write def I mean function.
User avatar
monsieur_h
Citizen
Posts: 69
Joined: Tue Oct 30, 2012 4:43 pm

Re: need help with anim8

Post by monsieur_h »

I ask it here since I'm encountering kind of the same problem:
Is there a library that implements a kind of RenderQueue? If not, what would be the best approach to make one?
scutheotaku
Party member
Posts: 235
Joined: Sat Dec 15, 2012 6:54 am

Re: need help with anim8

Post by scutheotaku »

monsieur_h wrote:I ask it here since I'm encountering kind of the same problem:
Is there a library that implements a kind of RenderQueue? If not, what would be the best approach to make one?
By that, do you mean depth sorting? e.g. you have two images. Image 1 is "closer" to the "camera" (i.e. the screen, the player) than image 2, so image 1 draws after image 2 (so that it will be on top of image 2).

If so, this may give you some ideas (though this sorts it by the images' y value...you'd want to sort it by a depth/z value):
https://www.love2d.org/wiki/Tutorial:Drawing_Order
Or this:
https://www.love2d.org/wiki/Skip_list:Drawing_Order

I also have a "draw table" with depth sorting in my framework (not a plug!). Feel free to "steal" any parts you like (you may want to read my description of the framework in the thread to understand it better/quicker): viewtopic.php?f=5&t=12238&p=73732
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: need help with anim8

Post by kikito »

monsieur_h wrote:I ask it here since I'm encountering kind of the same problem:
Is there a library that implements a kind of RenderQueue? If not, what would be the best approach to make one?
LÖVE makes the draw operations exactly in the order it receives them. So, if you want to make one image appear "behind" another one... you must draw it "before".

The easiest way is: put every image (or entity - whatever your "visual unit" is) in a table. Sort it using table.sort, probably with a custom function, and then parse the resulting table with a for loop, drawing every image in order.
When I write def I mean function.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests