Sign in to follow this  
jw405

Basic spritesheet help needed

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);
    
}
 

Share this post


Link to post
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);

}

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.