Create animations from single sprites?

35 views
Skip to first unread message

Phil

unread,
Dec 10, 2017, 9:43:27 AM12/10/17
to excaliburjs
Hi!
Most of the image resources I have are not aligned in rows and columns but are tightly packed, e.g. lots of resources from kenney.nl. This means I can't use them to create an ex.Spritesheet. Is there any way to create an animation from the single sprites from a texture? E.g. pass an array of {x,y,w,h} objects instead of indices on getAnimationByIndices?

Erik Onarheim

unread,
Dec 10, 2017, 10:32:56 AM12/10/17
to Phil, excaliburjs
Hi Phil,

Not yet, but I think your proposal is a great idea to handle tightly packed assets. Excalibur sprites are already just coordinates over a backing texture so it should be possible to build this pretty easily.

In the mean time you could construct each Sprite of the animation by hand and build an Animation that way. Animations are really just a list of sprites.

Load up the texture that contains the packed sprite sheet then plug in your values.

https://excaliburjs.com/docs/api/edge/classes/_drawing_sprite_.sprite.html

https://excaliburjs.com/docs/api/edge/classes/_drawing_animation_.animation.html

I'll open an issue on Excalibur for this to be more convenient off of spritesheets


On Sun, Dec 10, 2017, 08:43 Phil <philipp....@gmail.com> wrote:
Hi!
Most of the image resources I have are not aligned in rows and columns but are tightly packed, e.g. lots of resources from kenney.nl. This means I can't use them to create an ex.Spritesheet. Is there any way to create an animation from the single sprites from a texture? E.g. pass an array of {x,y,w,h} objects instead of indices on getAnimationByIndices?

--
You received this message because you are subscribed to the Google Groups "excaliburjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to excaliburjs...@googlegroups.com.
To post to this group, send email to excal...@googlegroups.com.
Visit this group at https://groups.google.com/group/excaliburjs.
To view this discussion on the web visit https://groups.google.com/d/msgid/excaliburjs/23db9c26-a8a4-454e-851e-917198439e77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Phil

unread,
Dec 11, 2017, 2:02:52 AM12/11/17
to excaliburjs
HI Erik!

Whaaaaat, I totally did not see that when going through the API (btw the link in the sidebar at http://docs.excaliburjs.com/en/latest/ to the v14 docs doesn't work).

Your suggestion works flawlessly, thanks!

this.addDrawing(new ex.Animation(this._engine, [new ex.Sprite(...), new ex.Sprite(...)], this._speed, true));

And done! Neat.

Thanks for the quick reply, I was really afraid I'd have to splice and re-arrange all my assets in columns/rows...

Cheers

Phil

Erik Onarheim

unread,
Dec 11, 2017, 10:53:26 AM12/11/17
to excaliburjs
Issue posted! https://github.com/excaliburjs/Excalibur/issues/918

We'll take a look at the docs tonight our automation that generates it is not working at the moment
Reply all
Reply to author
Forward
0 new messages