AdamRyanGameDev Posted February 28, 2018 Share Posted February 28, 2018 Good morining! From the API I believe animation is preloaded like so.... this.load.spritesheet('dude', 'src/games/firstgame/assets/dude.png', { frameWidth: 32, frameHeight: 48 } ); and then animated like so this.anims.create({ key: 'left', frames: this.anims.generateFrameNumbers('dude', { start: 0, end: 3 }), frameRate: 10, repeat: -1 }); However I would like to sometimes work off a list of .pngs eg face1.png, face2.png rather than a sprite sheet, how would I go about this via the animationManager, or would I have to manage it myself with a looping system of mine within the gameloop? Link to comment Share on other sites More sharing options...
rich Posted February 28, 2018 Share Posted February 28, 2018 Sure you can Here's a quick example I made: http://labs.phaser.io/view.html?src=src\animation\animation from png sequence.js and the code: var config = { type: Phaser.AUTO, parent: 'phaser-example', width: 800, height: 600, backgroundColor: '#fbf0e4', scene: { preload: preload, create: create } }; var game = new Phaser.Game(config); function preload () { this.load.path = 'assets/animations/'; this.load.image('cat1', 'cat1.png'); this.load.image('cat2', 'cat2.png'); this.load.image('cat3', 'cat3.png'); this.load.image('cat4', 'cat4.png'); } function create () { this.anims.create({ key: 'snooze', frames: [ { key: 'cat1', frame: null }, { key: 'cat2', frame: null }, { key: 'cat3', frame: null }, { key: 'cat4', frame: null, duration: 50 } ], frameRate: 8, repeat: -1 }); this.add.sprite(400, 300, 'cat1').play('snooze'); } CanDbas, makis and AdamRyanGameDev 2 1 Link to comment Share on other sites More sharing options...
AdamRyanGameDev Posted March 1, 2018 Author Share Posted March 1, 2018 That's great, thanks again! Link to comment Share on other sites More sharing options...
rich Posted March 1, 2018 Share Posted March 1, 2018 In the 3.2.0 release you can leave out the 'frame: null' part too, but you'll need it for the current version. AdamRyanGameDev 1 Link to comment Share on other sites More sharing options...
wexing Posted April 19, 2018 Share Posted April 19, 2018 Is it possible to do that on phase 2.6.2? Link to comment Share on other sites More sharing options...
rich Posted April 19, 2018 Share Posted April 19, 2018 Nope. You'll have to write your own timer to call `setTexture`. Link to comment Share on other sites More sharing options...
Recommended Posts