Jump to content

Failed to slice sprite sheet image into frames


Majirefy
 Share

Recommended Posts

I load a sprite sheet image file in preload states:

this.game.load.spritesheet('rings', Assets.Images.ImagesBlocksRings.getPNG(), 100, 100);

Assets.Images.ImagesBlocksRings.getPNG() returns url of image file like "../assets/rings.png".

Then I add a Phaser.Image object in main state:

this.ring = this.game.add.image(this.game.world.centerX, this.game.world.centerY - (this.game.world.centerY / 2), 'rings');

But when I run my game, instead of showing a frame, it shows the whole sprite sheet image, not slicing into frames.

If I change the key of sprite sheet to "_rings", it will work fine.

Or If I put load into the preload function in main state, it will work fine, too.

Why is that?

PS: I check the key in Phaser.Cache, it will return true unless after load.

Link to comment
Share on other sites

per the documentation:

new Phaser.Image(game, x, y, key, frame)

so you are missing an argument to specify the frame

ps: why is this forum using a rich text editor and not markdown? +.+

Link to comment
Share on other sites

On 2017/3/3 at 10:29 AM, ldd said:

per the documentation:


new Phaser.Image(game, x, y, key, frame)

so you are missing an argument to specify the frame

ps: why is this forum using a rich text editor and not markdown? +.+

Thanks. I found out. Because I used a Phaser Template. It loads everything in assets folder automatically and gives keys by file name. So this happened. 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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