Cocos2d-x 3.0 物理引擎小demo

来源:互联网 发布:js遍历object数组 编辑:程序博客网 时间:2024/05/09 14:11


Make a physics game use cocos2d-x 3.0(part 1)

They packed Chipmunk into Cocos2d-x 3.0. I don’t make a physics game before, but I think physics game is more interesting than others. Let’s go!(ps: I want to practice my English so it is in English…)

Runtime

  • Cocos2d-x 3.0
  • Windows 7
  • Python 2.7.5
  • Visual studio 2012(for windows)

Create A new Project 

         Please google  or baidu “how to create a project in cocos2d-x 3.0” 

  Here is my project :

          

Create A Pyhsics World

Following codes created a scene withphysics world and pass on child layer. Add codes in HelloWorldScene.h 


Andadd following codes to createScene method 

 

Create Pyhsics Boundary

In this version,everything need a node,following code show create physics boundary around the screen


Create a Ball

now,let's create a football in this world:


Run


ok,this demo is finished, if you want create more interesting objects,you can use thePhysicsEditor tools.





0 0