PixiGif master READ ONLY 0
  • explorer
  • search
a [App]
a CG.PixiGif
a README.md
a app.ts
a [Test]
a test
  • README.md

PixiGif

Add GIF 89a (animated GIF) support for pixi.js.

Getting Started

Add GIF image alias to resourceManager as regular resources, and create a GifSprite by CG.PixiGif.createGifSprite();

let resourceAlias = 'PixiGif.anim';
CG.Base.resourceManager.addAppResource(alias);
CG.Base.resourceManager.load(() => {
    CG.Base.pixi.initialize(300, 300);

    // create a GifSprite, attach to pixi.root and play the animation
    let sprite = CG.PixiGif.createGifSprite(resourceAlias);
    CG.Base.pixi.root.addChild(sprite);
    sprite.play();
});

You can setup custom sequences by any combination of frames.

let sprite = CG.PixiGif.createGifSprite(resourceAlias);
sprite.addSequence('jump', [1,3,5]); // define a sequence named jump
sprite.setSequence('jump', true); // set jump as the current sequence, and play

You can listen to events from GifSprite

let sprite = CG.PixiGif.createGifSprite(resourceAlias);
sprite.on('frameChanged', (sp) => console.log('the frame is just changed'));
sprite.on('complete', (sp) => console.log('the animation is complete and stopped'));
sprite.on('play', (sp) => console.log('just starts playing the animation'));
sprite.on('stop', (sp) => console.log('the animation is stopped'));
sprite.on('end', (sp) => console.log('the animation plays to the end of the sequence'));

References

READ ONLY
  • problem
  • console
No problems have been detected so far.
Ln 1, Col 1, Sel 0
Markdown