Jump to content

Failed to slice sprite sheet image into frames


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

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

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.

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.


  • Recently Browsing   0 members

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