Hey guys,
So I have been thinking of usecases where I want to use an animation library for all my entities in my game.
For Anim8 specifically, there are a set number of "grids" attached to images, and entities all have their own Animation which is basically a set of instructions of how the animation works (play frames 1 to 5 on grid1 for image1.png).
My use case, is I want to be able to crop / slice / cut a part of an image, as in, not display a fraction of the image, this being in constant dt time, so a healthbar image will decrease the top of the image as health decreases from 100%, back to 100%.
So let's assume we have 100 by 100 pixel image. I want to add 1 to the y, and subtract 1 from the height of the frame of the image, so the image goes from 100% to 99% all the way to 0, where it disappears. I've implemented this manually in an SDL2 game because all the properties of the "grid" and it's frames were accessible, but:
I don't see how this is possible in native Anim8, or Walt, or any other library. I know Quads can do this with maybe something like paste?
Basically I'm a bit lost as the best way to about about implementing this without me having to rewrite my own animation library. If I have to write custom code specifically for the few entities that require this cropping I think that's fine.
Cropping of quads easily? Anim8 / Walt library
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Cropping of quads easily? Anim8 / Walt library
love.graphics.setScissor is probably the best way.
Re: Cropping of quads easily? Anim8 / Walt library
Perfect, I think that will work!
Re: Cropping of quads easily? Anim8 / Walt library
So I figured out how to do this natively in Anim8.
Anim8 uses Quads as frames. Grabbing a quad (assuming 1 frame, for multiple have to loop over the frames and change them all or have a counter and change them pragmatically) and then using:
https://love2d.org/wiki/Quad:getViewport
https://love2d.org/wiki/Quad:setViewport
You can change the y and height parameters of the quad.
Then just apply that to love.graphics.draw (by decreasing / increasing x or y by 1) and it just works.
Hope this helps anyone else!
Anim8 uses Quads as frames. Grabbing a quad
Code: Select all
animation.frames[animation.position]
https://love2d.org/wiki/Quad:getViewport
https://love2d.org/wiki/Quad:setViewport
You can change the y and height parameters of the quad.
Then just apply that to love.graphics.draw (by decreasing / increasing x or y by 1) and it just works.
Hope this helps anyone else!
Who is online
Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot], Semrush [Bot] and 4 guests