Run Box2d on Mac

Actually I cannot create iphonetestbed project using the cMakeList.txt under Contributions/Platform/iPhone in my environment xcode 4.3.2, mac 10.7.3, cmake 2.8.7. I always got the error "xcodebuild cannot support -buildstyle". I try to create a xcode project for iphonetestbed manually according to the CMakeList.txt, it fails either, since the source code of iphonetestbed is not correct. It seems the Contribution is not sync with the Box2D source code. Finally it's proved I waste much time to do a stupid thing.

Abandon this way, I try to start use Box2D directly follow a good tutorial from: http://www.cocoanetics.com/2010/05/physics-101-uikit-app-with-box2d-for-gravity/. Also I post my summary about Box2D, most of these are from Box2D FAQ.

Box2D is a feature rich 2D rigid body physics engine, written in C++. It users the zlib license and can be used free of charge. The zlib license does not require attribution, however you should give credit to Box2D when possible. Programmers can use it to make objects move in believable ways and make the game world more interactive. From the game engine's point of view a physics engine is just a system for procedural animation.


1.1  major features (You can find more detail from the end of this email) 

-- collision(continuous collision detection, contact callbacks ...)

-- physics(continuous physics with time of impact solver, joint, contact, friction and restituion) . 


1.2 some important things

--Box2D is only physics engine, don't render anything.

--Box2D is tuned for meters-kilograms-seconds (MKS). Therefore do *NOT* use pixels as units. To convert pixels to meters, we need a fix conversion rate between pixels to meters, such as 100 pixels=1meter. In our demo project box2dworld we set 16pixels=1meter.

--Box2D may have accuracy issue because:

   performance

   some differential equations don't have known solutions

  some contraints cannot be determined uniquely


How to setup iphonetestbed

1. run Box2d testbed

1.1 download and install CMake. Download from http://www.cmake.org/cmake/resources/software.html

1.2 Xcode 4.3 is installed as application in /Applications, therefore add Xcode usr/bin into $PATH. Create ~/.bash_profile if it doesn't exist, add below command at the end of this file:

export PATH="$PATH:/Applications/Xcode.app/Contents/Developer/usr/bin/" 

1.3 xcode-select the XCode folder via below command:

sudo xcode-select -switch Applications/Xcode.app/Developer

1.4 do below things as instruments from http://gamedev.stackexchange.com/questions/11036/getting-started-with-box2d-for-ios

========================

Ok finally got something to work (this was helpful: http://box2d.org/forum/viewtopic.php?f=18&t=6580&p=29800&hilit=cmake#p29800)

Anyways here's what I did:

  1. get Box2D source like this: "svn checkout http://box2d.googlecode.com/svn/trunk/"
  2. In the Terminal navigate to "Contributions/Platforms/iPhone"
  3. In the Terminal do "cmake -G Xcode"
  4. Double click on "iPhoneTestbed.xcodeproj" in the Finder

Now this Xcode project actually builds and will run in the simulator. There's some cool demos of Box2D physics. Hope this is helpful :-)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值