Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

loadTexture help


Catrin
 Share

Recommended Posts

Hello, I am new at this and I need help.

I am using v3 to make a small game in which a sprite has to change appearance upon an event. I was trying to use the Phaser 2 example below:


var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create });

function preload() {

    game.load.atlasJSONHash('bot', 'assets/sprites/running_bot.png', 'assets/sprites/running_bot.json');
    game.load.spritesheet('mummy', 'assets/sprites/metalslug_mummy37x45.png', 37, 45, 18);

}

var bot;

function create() {

    bot = game.add.sprite(200, 200, 'bot');

    bot.animations.add('run');

    bot.animations.play('run', 15, true);

    game.input.onDown.addOnce(changeMummy, this);

}

function changeMummy() {

    bot.loadTexture('mummy', 0);

    bot.animations.add('walk');

    bot.animations.play('walk', 30, true);

}

But I keep getting "player.loadTexture is not a function" error. I assume the equivalent of in Phaser 3 is different, but I can't find it.

Any help will be appreciated.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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