Skip to content
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

Merged
merged 8 commits into from
Feb 11, 2016
Merged

Feature game over state #12

merged 8 commits into from
Feb 11, 2016

Conversation

tomcraven
Copy link
Contributor

No description provided.

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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)
@marc-jones
Copy link
Contributor

All looks good to me!

@tomcraven
Copy link
Contributor Author

schweet, thanks

tomcraven added a commit that referenced this pull request Feb 11, 2016
@tomcraven tomcraven merged commit e99f399 into development Feb 11, 2016
@tomcraven tomcraven mentioned this pull request Feb 11, 2016
@marc-jones marc-jones deleted the feature_game_over_state branch February 11, 2016 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants