Sign in to follow this  
Majirefy

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.

Share this post


Link to post
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? +.+

Share this post


Link to post
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. 

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.