-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature game over state #12
Conversation
this.offset_x = this.offset_x + | ||
(ship.body.position.x - ship.body.prev.x); | ||
ship.body.position.setTo(ship.body.prev.x, ship.body.position.y); | ||
npo_sprite.body.position.x -= shipXPositionDiff; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is occasionally throwing an error for me: Cannot read property 'position' of null
Printing __non_player_objects to the console reveals that the array contains a single sprite, then suddenly contains multiple sprites when the error occurs. The number of additional sprites coincides with the number of times you have died and clicked restart, which makes me think that the __non_player_objects array isn't properly deleted between changes of state. Maybe move its initialization back to the 'create' function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh that's a good catch. So it looks like phaser doesn't create a new instance when you switch states..?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess not, but what's a bit weird is how it's works fine for a bit and then errors all of a sudden without the player doing anything particularly different. Still, an easy fix even if the cause is still a little hazy!
…tialised between transitions (but it doesn't)
All looks good to me! |
schweet, thanks |
No description provided.