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

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

  • Recently Browsing   0 members

    No registered users viewing this page.