Jump to content

Draw sprite animation from a single image? (Pixi v5)


que
 Share

Recommended Posts

Hello everyone,

I'm new to Pixi, and so far I'm very impressed with the performance and ease of use...

There's one thing I can't find any examples/resources on how to do, and that is how to draw a sprite animation.

 

I have this sprite below, which I'd like to split up and be able to animate. 


I can't define what sprites I will need in setup, so I'd like to be able to load it 'on the fly'. I can do this with regular sprites with this piece of code:

var textures = new Map();
function getSprite(url) {
    let texture = PIXI.Texture.from(url);
    textures.set(url, texture);

    return new PIXI.Sprite(textures.get(url));
}

 

bd33950265771df74aeafb3baa2b2ff2.png

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...