7HzG

Phaser Mdule Pattern and Sprites

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!!

Share this post


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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.