Jump to content

AnimationSprite with multiple animations?


Recommended Posts

Done :)

Check it out here: https://servercharlie.bitbucket.io/1-PIXI-Animated-Sprites.html

I've listed 5 possible ways of doing it, and I'm still finishing up the other demos. But actually with the first demo + list of demos provided you'll already get the gist of it: You index everything you want to load into object, then you just iterate through them with 1.) the pixi loader, for loading the assets; and 2.) assigning the textures once assets are loaded, and 3.) switching the textures in-game.


Link to comment
Share on other sites

    // Temporary 'frame object' now created.
    // 1.) Its texture is directly loaded from an Image.
    //      - our sprite model is a cowgirl,
    //      - with an 'Idle' animation where she just stands comfortably.
    // 2.) Take note of the 'time' property,
    //      - it is length in milliseconds of how long to display the frame.
    //      - we use 50ms, but you can experiment with higher/lower values.
    Temp_Frame = {
        texture: PIXI.Texture.fromImage(`./game_assets/cowgirl/Idle (${i}).png`),
        time: 50


Thanks for guide! Unfortunately, time property feature is undocumented and doesn't work for me. I am using last version of pixi.js - v4.3.4. Do I need dev version or something?

Link to comment
Share on other sites

Not sure what you mean by "undocumented" but I was actually using the same v4.3.4 version in the example, I even went back moments ago and tested switching the 50ms to 100ms & 200ms, and it was actually working on my end :unsure: 

I just checked the latest version's source on github btw, the 'time' property is already there as it should be: https://github.com/pixijs/pixi.js/blob/873ea67dd6167e2ddb1c2642a1bda0fd8a263e82/src/extras/AnimatedSprite.js#L3-L8

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.

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.


  • Recently Browsing   0 members

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