Created
February 22, 2020 19:17
-
-
Save blurymind/00ec2d25147af70149dba8f0e5e917f9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
prepareAnimationStrip(frames) { | |
let renderer = this.app.renderer; | |
const rect = new PIXI.Rectangle( | |
0, | |
0, | |
this.tilewidth * frames.length, | |
this.tileheight | |
); | |
var container = new PIXI.Container(); | |
console.log(container); | |
frames.forEach((frame, frameIndex) => { | |
const frameTexture = this.prepareTexture(frame.tileid); | |
console.log(frameTexture); | |
frameTexture.frame = rect; | |
if (frameIndex > 0) frameTexture.x = (frameIndex + 1) * this.tilewidth; | |
var sprite = new PIXI.Sprite(frameTexture); | |
//////// | |
container.addChild(sprite); | |
}); | |
var tex = renderer.generateTexture(container, { | |
width: this.tilewidth * frames.length, | |
height: this.tileheight, | |
autoResize: true, | |
}); | |
const texture = new PIXI.Texture(tex); | |
texture.cacheAsBitmap = true; | |
console.log('COMP:', texture, tex); | |
return tex; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment