SpaceCowboy2071 Posted September 20, 2016 Share Posted September 20, 2016 Hi, I'm banging my head against the desk try to get spritesheets working in PixiJS. When I began the project, v3 was still current so I'm hoping to stick to that version just to get this project out the door. So, rather than use a JSON file, I'm opting to just loop through creating frames from a single image. I've already found a few posts here and elsewhere on how to do it, but the end result is not working. I'm scratching my head as to what I'm missing. All I get is the first frame. I'm loading all textures using the PIXI Loader then basically using this script: var base = PIXI.utils.TextureCache[ "img/spritesheet.png" ]; var aryTextures = []; var frameWidth = 525; var frameHeight = 700; var i = 0; var length = 12; var col; var row; var colMax = 12; for ( i; i < length; i++ ) { row = Math.floor( i / colMax ); col = i - row * colMax; var texture = new PIXI.Texture( base ); var rect = new PIXI.Rectangle( frameWidth * col, frameHeight * row, frameWidth, frameHeight ); texture.frame = rect; aryTextures.push( texture ); } var mc = new PIXI.extras.MovieClip( aryTextures ); mc.loop = false; mc.onComplete = function() { /*do stuff*/ }; myStage.addChild( mc ); mc.gotoAndPlay( 0 ); Still on my first project with PixiJS, so sorry for my noobiness! Thanks! Quote Link to comment Share on other sites More sharing options...
SpaceCowboy2071 Posted September 20, 2016 Author Share Posted September 20, 2016 Ah, nevermind. This is working just fine, I just exported the spritesheet incorrectly from Photoshop. Doh! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.