Jump to content

Phaser Mdule Pattern and Sprites


7HzG
 Share

Recommended Posts

Hi guys may I ask a quick question? I'm working with Phaser and I'm using the module pattern, creating a module that has a prototype of Object.create(Phaser.Sprite.prototype) and creating an instance of that in the main module. The problem is the sprite seems to be created in the main module in the create function but the image of the sprite is not loading and i cant find the problem or set the image.

Thanks so much!!

Link to comment
Share on other sites



//game.load.spritesheet('playersheet', 'resources/data/Towers/coffee-tower-mit-hintergrund.png', 64, 64);
Player = function(game, x, y){
    game.load.spritesheet('playersheet', 'resources/data/Towers/coffee-tower-mit-hintergrund.png', 64, 64);


    Phaser.Sprite.call(this, game, x, y, 'playersheet');
this.anAttribute = 'whatever'; this.anotherAttribute = 20;};
Player.prototype = Object.create(Phaser.Sprite.prototype);
Player.prototype.constructor = Player;

 

throws:

Phaser.Loader - script[Player]: error loading asset from URL resources/js/Player.js
Phaser.Cache.getImage: Key "playersheet" not found in Cache.

main:

in preload

game.load.script('Player', 'resources/js/Player.js');

 

in create

testPlayer = new Player(game,77,77);
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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