Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build a Game with Sprite Kit Particle Systems and Keeping Score Finishing Touches

Jason Meinzer
Jason Meinzer
3,679 Points

Buggy game restarts?

Anybody else having issues restarting the game after a game over? I've quadruple checked my code, backed up several videos, etc. and haven't had any luck fixing this.

Basically, the game over happens, I click to restart, and half the time the game will restart without any issues but the other half of the time it restarts and both the space dogs and fireball projectiles are hidden from the screen. You can shoot, the noise effect still plays, but you can't see the projectile. The dogs are falling, because the explosion animation happens when they hit the floor, but you can't see them falling. It's like they're all hidden behind the screen or something.

The life tracker decrements each time a space dog hits the floor, too.

I've messed around with their z-coordinates to no avail.

Any thoughts?

Again, odd, because half the time there are no issues and the other half of the time these issues occur.

1 Answer

try adding this code inside of the touches began method's else if statement

scene.zPosition = -1;

the scene being the new THGameplayScene. The position of the THGameplayscene will push it back while the other nodes appear in front of it