Jump to content

Basic spritesheet help needed


jw405
 Share

Recommended Posts

Hi!

 

Very new to programming and Phaser so be kind!

 

I've just downloaded Phaser and have been playing around with spritesheets. I managed to get my first sprite animated using the master phaser example tutorials (http://phaser.io/examples/v2/sprites/spritesheet#download).

 

I then tried adding a second spritesheet in a different location but it doesn't seem to play the animation (original spritesheet still loads and plays though)?

 

I've read somewhere that using a tilemap when using multiple spritesheets is advised.

 

Any help would be hugely appreciated! Cheers!

 

Here's the code:

 
function preload() {
 
    game.load.spritesheet('ms1', 'assets/sprites/bee-2-sprite.png', 72, 60, 2);
    game.load.spritesheet('ms2', 'assets/sprites/bee-3-sprite.png', 58, 52, 2);    
}
 
function create() {
 
    sprite = game.add.sprite(50, 100, 'ms1');
    
    sprite = game.add.sprite(150, 100, 'ms2');
 
    sprite.animations.add('walk');
    
    sprite.animations.play('walk', 10, true);
    
    var fly = ms1.animations.add('fly');
    
    ms1.animations.play('fly', 10, true);
    
}
 
Link to comment
Share on other sites

function preload() {

game.load.spritesheet('ms1', 'assets/sprites/bee-2-sprite.png', 72, 60, 2);

game.load.spritesheet('ms2', 'assets/sprites/bee-3-sprite.png', 58, 52, 2);

}

function create() {

// we need to assign our sprites to variables - we'll use ms1 and ms2

var ms1 = game.add.sprite(50, 100, 'ms1');

var ms2 = game.add.sprite(150, 100, 'ms2');

// add our walk animation to ms1 and play it

ms1.animations.add('walk');

ms1.animations.play('walk', 10, true);

// add our fly animation to ms2 and play it

ms2.animations.add('fly');

ms2.animations.play('fly', 10, true);

}

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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