Sign in to follow this  

Cannot load spritesheet in Phaser

Recommended Posts

I have this spritesheet:




And I use this code to load it into my game:

wml.loadSpriteSheet('GUIDE_BUTTONS_SHEET', null, 'assets/images/UI/guideButtonsSheet.png', 50, 60, 8);

Where loadSpriteSheet() is a helper function that uses game.load.spritesheet() from Phaser.Loader class. 

The dimesions 50 width and 60 height per frame are just too small for the real size of the spritesheet. The real width and heigth of it is

196x156. I set it to 50x60 so that the game can load without giving error. Anything above 50 width gives error in Firebug.


Can somebody give me a clue why it refuses to load the image?

Can the irregular form of the frame cause some trouble?


The error in Firebug:

Error: Texture Error: frame does not fit inside the base Texture dimensions [object Object]

Share this post

Link to post
Share on other sites

What does the null parameter in your function do? According to the docs, .load.spritesheet takes arguments key, url, frameWidth, frameHeight. Since you're loading through a custom function I'm assuming it's not related to this, but I thought I'd mention it.


The parameters frameWidth and frameHeight define the height of one frame in your spritesheet, so setting them to 196x156 (the full size of your image) may not be what you want. Especially if the code then goes looking for 8 frames of the specified frame size in the sheet (as per your last parameter). The size of one frame in your sheet would be 98x39px from what I can tell.


I've never encountered this error for myself, though. If this doesn't fix it, try to find out what's inside the [object Object] in the error, maybe that could tell you a bit more.

Share this post

Link to post
Share on other sites
loadSpriteSheet: function (keyName, keyValue, url, width, height, numOfFrames) {    thisObject.addConstant(thisObject.ImageAssetKeys, keyName, keyValue);    game.load.spritesheet(thisObject.ImageAssetKeys[keyName], url, width, height, numOfFrames);}

Yes yes, 156/4 = 39 :D

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.