Box2D breakout prototype
2009-10-27 00:00:00 来源:WEB开发网Porting Breakout/Arkanoid with Box2D seems to be an interesting challenge for developers.
Some days ago I showed you Phyballs, now it’s time for Andre Vidal to show his work.
Andre runs his own blog I suggest you to visit because you will find some interesting source code.
This is Andre’s breakout
(arrow keys = left and right paddle )
( everything is draggable with the mouse )
He used all the basic techiniques you ought to learn before adventuring into professional use of Box2d.
The bricks are hanging by distance joints attached to the body Ground, the paddle is fixed on the x axis by a prismatic joint attached also to the Ground.
The code looks for only 2 collisions, on ball against the paddle an Impulse is applied to the ball and on ball against a brick the brick distant joint is broken and the gravity acts on the brick (which makes it fall down).
本文示例源代码或素材下载
更多精彩
赞助商链接