Show HN: Flappy Block – Flappy Bird clone using the iOS7 Physics Engine
github.com
github.com
SpriteKit - Contains a 2D physics engine similar to Box 2D but not as full featured (joints, rigid bodies, shapes, polygons). The whole engine is similar to Cocos2D but ships with iOS 7. A particle editor and texture atlas generator is now built-in to Xcode because of it.
UI Dynamics - Contains a set of constraints and joints which can be used to flip and throw views around the screen. Lots of API hooks for responding to / taking user interaction into account. This is used for effects like when you scroll the messages list (the message bubbles bounce and collide) or when you drop notification center down (it bounces).
Edit: from a brief look at the source code, this example uses the UIDynamicAnimator API, so it is simulated entirely with the UI dynamics stuff.
Same thing applies to UIKit Dynamics, except it plays along with UIKit stuff.
According to my tests it is not Box 2D, it produces significantly different results and only implements a subset of functionality. I've been told by others with more experience that it isn't Box 2D also, but if you have more information I'd like to know for sure.
https://ghostbin.com/paste/tm4ko
b2* shows up in there many times.
edit: slow pony
However, this seems like just a remake of the helicopter game, which is fair enough, but hardly a feat of engineering. So, if this is the case, then what is this about using a "physics engine"? Determining if rectangles intersect seems a bit too trivial to me to be of interest, and I'm just confused what it is doing here.
One example is the iOS7 notification center; If you drag it down and "slam" it to the bottom of the screen, it has some bounce. A second example is the Messages chats when scrolling quickly; You'll notice that as the swipe seed increases you get more space between peoples chat comments and they kind of slam together when you stop scrolling.
What I aimed to do here is take that same engine and use it to build FlappyBlock. So instead of having a loop that says:
while () { // Pipe is not on the left
movePipeOnePixelLeft(); // Move Pipe one pixel over
if (at the left) break; // If we hit the left, end loop
}
Physics would say something like this: givePipeMassAndLocation(); // Give Pipe physical properties
pushPipeLeftWithForceVector(); // Push pipe to left with force
whenPipeHitsLeftWallRemove(); // Remove the pipe when it his the left
It's a different way of attacking the same problem using features many newer developers are not familiar with in iOS7.