whitebrim / animatedsprite Goto Github PK
View Code? Open in Web Editor NEWSprite class extension with imagetable animation and finite state machine support for @Playdate
License: MIT License
Sprite class extension with imagetable animation and finite state machine support for @Playdate
License: MIT License
Seeubg that the default way to add images is through an imagetable, is there a way to add images as drawTiled images instead?
Would there be any way to combine sprites somehow? Let's say I have a character sprite with some different frames for body movements, and then a second sprite for facial expressions...
I'm curious as to why the initializer takes an imagetable
instead the the path string itself. Is there a common use case for keeping a reference to the imagetable
outside the sprite? As it stands, it feels like one unnecessary line of setup code.
To avoid a breaking API change, you could do something like:
if type(imagetableOrPath) == "string" then
self.imagetable = gfx.imagetable.new(imagetableOrPath)
else
self.imagetable = imagetableOrPath
end
This utility is fantastic, but its utility is limited by the fact that it only supports frame-based animation. Although switching to time-based animation would likely require a fair amount of work, the approach seems relatively straightforward given that you could use a playdate.graphics.animation.loop
to handle the frame tracking. Its properties seem well positioned to provide everything you'd need to support the current JSON config and API as it is today.
Technically this would be a breaking change and could impact some games when compiled against the new version, though you could minimize that significantly by setting a default delay on the loop
object based on playdate.getFPS()
.
This may be more a question rather than a bug report.
I like to have my sprites in a separate class for each. I nonetheless couldn't manage to extend this class, is there a good way to do it?
Thank you
Hi - maybe I'm wrong but there seems to be no event called when animation starts ?
In my case that would be quite handy as I'm animating a muzzle flash which should disappear from the screen when animation ends (basically using setVisible(false)
method of a sprite class.
It looks like this (thought that maybe onStateChangedEvent
is gonna be called after each playAnimation()
but apparently not:
local bang = gfx.imagetable.new( "images/fx/muzzleFlash1_01" )
self.bangAnim = AnimatedSprite.new( bang )
self.bangAnim.states.default.onAnimationEndEvent = function (self) self:setVisible(false) end
-- unfortunately not called after each playAnimation() call:
-- self.bangAnim.states.default.onStateChangedEvent = function (self) self:setVisible(true) end
-- something like this would be helpful:
-- self.bangAnim.states.default.onAnimationStartEvent = function (self) self:setVisible(true) end
end
Or am I missing some other obvious way of achieving this "one-shot" (pun intended) animations that do not stuck at displaying last frame when animation is finished ?
Hello ! It looks like the :setScale
method isn't working on AnimatedSprite. Is that a playdate limitation or just something that's missing ?
Thanks for making this library I look forward for more information !
Hello @Whitebrim !
I am using AnimatedSprite for a game I am making where there are some sprites (around 30 max) that are animated.
Unfortunately, it look likes there is a memory leak when updating animations every frame... I don't know how specific this is to my code but what I can show you is the stats window of the device (I ran the game on device to check real performances).
I have looked into the profiler and determined that this indeed comes from calling updateAnimation() every frame.
One thing though, I am not making a class to create objects, I am just storing objects in a table and I have function that creates them like a class because for some reason Playdate SDK won't allow to extend a class from a class that already is extended from something.
I'll be glad to provide more informations and even contribute to AnimatedSprite. Looking forward to your answer and have a nice day !
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.