Jump to content

texturepacker to a sprite sheet of many different entities


aylictal
 Share

Recommended Posts

Hello-

I recently started a phaser 3 project and it has been nice so far.  I use Tiled and got a huge tilemap in my game and am really happy with it so far.

What i need help with is to load an atlas sprite sheet and then create animations off of that sprite sheet.  I tried doing this using something like this:

 

class Level1 extends Phaser.Scene {

preload(){
    this.load.atlas('players', 'img/players.png', 'data/players.json');
}

create(){
    this.player = this.add.sprite(400, 300, 'players');
    this.player.setScale(2);
    this.anims.create({
        key: 'move',
        frames: this.anims.generateFrameNumbers('players', {
            start: 4,
            end: 6
        }),
        frameRate: 10,
        repeat: -1
    });
}

update(){
    if (this.cursors.left.isDown){
         this.player.anims.play('move', true);
    } else if (this.cursors.right.isDown){
         this.player.anims.play('move', true);
    }
}
}

Is this possible, and if so is there a good tut of doing this?  I have lots of sprites i want to incorporate and they're all packed into the same file, but I only wish to designate certain frames as the respective animations.

Currently gettin exception:

phaser.js:82237 Uncaught TypeError: Cannot read property 'frame' of undefined
    at Animation.updateFrame (phaser.js:82237)
    at Animation.load (phaser.js:75059)
    at AnimationManager.load (phaser.js:74039)
    at Animation.load (phaser.js:81840)
    at Animation.play (phaser.js:81924)
    at Overworld.update (Overworld.js:49)
    at Systems.step (phaser.js:30316)
    at SceneManager.update (phaser.js:62911)
    at Game.step (phaser.js:115769)
    at TimeStep.step (phaser.js:112963)

Edited by aylictal
missed quote
Link to comment
Share on other sites

  • 1 month later...
 Share

  • Recently Browsing   0 members

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