Sign in to follow this  

init parameters is undefined

Recommended Posts

In Phaser 2.7.5 I'm trying to pass an object as a parameter from one state to another but the object is showing as undefined.

Below is the code from GameState whereby I'm looking to pass an object containing a score, time and seconds.
        score: this.killedGerms,
        time: this.timeLabel.text,
        seconds: this.remainingSeconds

Below is the CongratulationsState where the parameter, "data", is coming through as "undefined".

init: function(data) {
    console.log('data', data);

    data = data || {
      score: 0,
      time: "00:00",
      seconds: 0

Any ideas on where I have gone wrong would be greatly appreciated.

Edited by smdool
changed "null" to "undefined"

Share this post

Link to post
Share on other sites

@smdool Okay so no data is passed at all then. Maybe you have another state.start('Congratulations'); call somewhere, which starts the CongratulationsState without passing anything? Sorry I can't be more helpful than that :( I would need to see the complete code for both states to say more. You can send me the files for these two states if you want to and I'll have a look at it.

Share this post

Link to post
Share on other sites

Thanks @jamespierce.

I think the issue is because I had previously been using phaser-state-transition.min.js to animate state transitions. I had recently stopped using phaser-state-transition while I was testing something out but hadn't removed the script tag from index.html. This appeared to be overriding the normal function.

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.