Hey friends, I recently went through the “How To Make A Game Like Flappy Bird” Tutorials. Although I do understand they are dated, I would love some help. The game is completed and looks great although I realized you can jump off screen over the obstacles entirely. Even when I download the completed version, same issues… Help smh
Hi @iosdeveloperisaac,
Most of the sample, tutorial code are written to illustrate and help users understand something, which is mainly basic. Most of the tutorial writers take care to check for issues, however there can be edge cases that slip through.
However I don’t understand the problem you are mentioning, so if you detail it with the code or a screenshot/video someone can respond better.
Hi. I think I maybe able to help. It sounds like you are able to jump up off the top of the screen. What device are you running it. Is it an actual iPhone or simulator?
In GameScene.swift there is a method called setBackground(). There is a field called playableStart and playableHeight. Print out the playableHeight. I bet that it is off screen. Try running it on different devices also.
Another spot to look is in GameViewController.swift. In the method viewWillLayoutSubviews() there is where it Print out the Aspect Ratio.
This fields will give us enough information to figure out what is happen. I will work with you to get this resolved. I’m Nick nice to meet you.
he code looks right Try this as a test. Change this line of code below in the setBackground. We are trying to determine if the issue is with your playableHeight being wrong or if it is an issue with the code that uses the playableHeight to determine if it is off the screen. What this will do is only let your bird fly between the ground and 200 points above the ground. So it should not go very high. I’m in the process of downloading Xcode 8 on another mac i have so i can see what you seeing.
Here is a fix that should run on all iPhones except for any of the iPhone X’s.Try it with iPhone 6, 7 and 8 it should work. This code was written before the iPhone X’s where announced. When I have time i will get it working on those but I will not have time today to do it.
under component folder there is a program MovementComponent.swift.
in method applyMovement please the add code that’s starts with // Add to // END
at the bottom of the method.
// Add this block of code
// off screen
let background = SKSpriteNode(imageNamed: “Background”)
let playableHeight = background.size.height
if spriteNode.position.y - spriteNode.size.height / 2 >= playableHeight + 100{
spriteNode.position = CGPoint(x: spriteNode.position.x, y: playableHeight + 100)
}
// End of block of code
blank out both double quotes and use your keyboard double quotes. Sometimes when you copy and paste they get converted If that does not work That same line of code is in GameScene in setBackground method Just copy and paste from there
great it work for some reason they never put the code in to stop your character from flying up and over. if you get stuck again email me at dominicdaws@gmail.com