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!
need help with anim8
need help with anim8
Last edited by tomshreds on Tue Feb 19, 2013 4:33 am, edited 1 time in total.
-
- Party member
- Posts: 235
- Joined: Sat Dec 15, 2012 6:54 am
Re: need help with anim8
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)?
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)?
- master both
- Party member
- Posts: 262
- Joined: Tue Nov 08, 2011 12:39 am
- Location: Chile
Re: need help with anim8
I bet, it is overlapping. Try to draw the background first and then the player by changing their position on your code.
Re: need help with anim8
It was a typo when I wrote the example code. Yes we see the rectangle but the animation is over it.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)?
Thanks!
Re: need help with anim8
I don't think so since the draw order is: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.
- background
- player
- rectangle
:-/ Thanks
Re: need help with anim8
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.
Damn.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: need help with anim8
Well, thank you, you are very kind, but it's still not perfecttomshreds wrote:I'm using anim8 for my animations, it's a perfect solution and I love it.
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.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.
When I write def I mean function.
- monsieur_h
- Citizen
- Posts: 69
- Joined: Tue Oct 30, 2012 4:43 pm
Re: need help with anim8
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?
Is there a library that implements a kind of RenderQueue? If not, what would be the best approach to make one?
-
- Party member
- Posts: 235
- Joined: Sat Dec 15, 2012 6:54 am
Re: need help with anim8
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).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?
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
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: need help with anim8
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".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?
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.
Who is online
Users browsing this forum: Ahrefs [Bot], CharlesAceta and 2 guests