Jump to content

Problem with States and methods


elsioneto
 Share

Recommended Posts

I`m currently using phaser 2.0.2 and I implemented some states transitions on my game due to load issues.

 

Before the transitions, the game was working fine, now, some methods aren`t working, such "revive"on the sprites, and every time I instantiate some image or sprite the "game" property on it comes null. 

 

Does anyone knows something about it?

Link to comment
Share on other sites

Hmm, ok i'll try to be more clear

 

I had a game working fine, with some menu, levels and etc... But I was loading everything at once in the PreLoader, and that was making the loading very slow.

 

So I planned to use a state for each level with it's own PreLoader and Create, so I subdivided every asset needed to load by level.

 

but some things just don't work anymore when I try to load de first level(quiting from the "Menu"state and starting de "Level1"state).

 

making  a debug, it seems that some properties on the objects that Phaser automatically sets, it's not setting anymore. For example, every sprite or image comes with "game" property, pointing to the game created (Phaser.Game(params)) , but now it's not coming anymore(in the 'Level1' state). And it's happening series of errors (if I try to revive an image a get a 'Uncaught TypeError: Cannot read property 'length' of undefined' ).

 

Hope it were more clear this time...

Link to comment
Share on other sites

I've had similar issues - usually it's due to adding an object to the wrong parent or something like that. I suggest you put a conditional breakpoint on the phaser.js line in question in Chrome's debugging tools. That will tell you at least what is undefined, and you will be able to give us more information.

 

To clarify, if the line it's breaking on has "children.length" then put a conditional breakpoint of with the condition "children == undefined".

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.

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

  • Recently Browsing   0 members

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