Box2D Forums

It is currently Wed Jul 23, 2014 12:52 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Objective C Wrapper
PostPosted: Thu Nov 10, 2011 5:29 am 
Offline

Joined: Wed Nov 09, 2011 8:08 am
Posts: 2
Hi guys,

I'm very new to game development, but I've some experience with iOS. So I started with cocos2d, which is pretty cool. Coming to physics, I investigated chipmunk and box2d for my suitableness. I decided for box2d because I don't like "crypted" C code and I appreciate object oriented development.

That said I also like clean ObjC code. Therefore I was looking for a wrapper, which supports full ObjC with not mixing C++. I found CCbox2d, which is a mix of cocos2d and box2d. This is surely a great way to combine both frameworks, but I would prefer a clean box2D wrapper - without linking the cocos2d or any other framework (e.g. sparrow). The TRBox2D wrapper by Tim Roadley is also bound to cocos2d.

So, what I'm asking is: Is there a need for pure box2D ObjC wrapper? Or, are all iOS developer comfortable using C++ and maintain ObjC/C++ code at all. From an iOS developer point of view, wouldn't it be grate to have ObjC (wrapper) code inside of box2d. What is the reason for not having it? Is it just because nobody hasn't started it yet?

Thanks,
iAMjazer


Top
 Profile  
 
 Post subject: Re: Objective C Wrapper
PostPosted: Thu Nov 10, 2011 8:22 pm 
Offline

Joined: Tue Sep 25, 2007 2:22 pm
Posts: 516
I took the opposite approach. Objective C means no Flash support (with Alchemy), no Android/BlackBerry support (with NDK), and no Windows support. I feel that Objective C takes the new/delete mismatch problem and smears the mess around the entire codebase. Also, there was an informative John Carmack interview about making Rage for iPad, where he showed conclusively that Objective C is very slow. Even Angry Birds cannot get a smooth 60fps on iPad because of its reliance on Objective C.


Top
 Profile  
 
 Post subject: Re: Objective C Wrapper
PostPosted: Fri Nov 11, 2011 5:11 pm 
Offline

Joined: Wed Nov 09, 2011 8:08 am
Posts: 2
Hi pTymN,

thanks for your thoughts. ObjC ist managed code and requires runtime . I'm just curious, what are the alternatives? Currently I just know about 2 iOS game engines, which are both coded with ObjC. What would be a good/performant option?

Thanks,
iAMjazer


Top
 Profile  
 
 Post subject: Re: Objective C Wrapper
PostPosted: Tue Dec 06, 2011 2:54 am 
Offline

Joined: Tue Dec 06, 2011 2:43 am
Posts: 6
This tutorial I use a simple wrapper I wrote for Box2D, good for beginners


Top
 Profile  
 
 Post subject: Re: Objective C Wrapper
PostPosted: Thu Apr 04, 2013 10:56 am 
Offline

Joined: Thu Apr 04, 2013 10:43 am
Posts: 3
I just came by this post by chance. I happen to be working on an Objective-C wrapper for Box2D, the rudimentary stuff is practically done (bodies, fixtures, shapes, collision callbacks). I'll be adding joints soon. The KTPhysicsController and related classes are part of KoboldTouch and not available separately. Perhaps if there's enough demand I'll look into making a standalone version.

The wrapper's used in combination with the KTPhysicsBodyModel, the model then updates the view's position & rotation, so you can actually connect any kind of view (sprite, label, particle effect, draw primitive, custom drawing node, even tilemaps if you wish) with the physics body. The wrapper also allows you to delete bodies right in the collision callback because it knows when the physics world is "stepping" and if so, simply puts all to be deleted bodies in a queue for deletion right after stepping completes.

There's one other ObjC Box2D wrapper I know of: GBox2D by Andreas Löw (PhysicsEditor, TexturePacker). Not complete though (no joints) and rarely updated.

I believe the reason why we haven't seen many ObjC wrappers for Box2D is that developers using it on iOS are quite often used to C++, perhaps they even used Box2D before. On the other hand if you wanted an ObjC physics engine then cocos2d developers specifically flocked to SpaceManager and some to Chipmunk Pro, so perhaps those interested in ObjC physics (and didn't care which one was under the wraps) were satisfied with that. I also believe Chipmunk was in greater need for a more readable ObjC interface due to its ambiguous variable names (r, f, m, i instead of restitution, force, mass, and whatever i stands for) - specifically for inexperienced developers. Box2D has a more readable API to begin with, so there's less need to make the API easier to work with, which is one of the driving reasons to start a wrapper besides the language differences.


Top
 Profile  
 
 Post subject: Re: Objective C Wrapper
PostPosted: Sun Apr 07, 2013 4:17 pm 
Offline

Joined: Tue Sep 25, 2007 2:22 pm
Posts: 516
I have a custom C++ engine, and I think most of the popular 3D open source engines have been ported to iOS at this point. They are weak on some points that Cocos2D is strong on, but if you need portability and top speed, unfortunately, you must avoid Objective C. I'll be looking to make this engine available to indy developers, but after the game I'm making on it finally ships.


Top
 Profile  
 
 Post subject: Re: Objective C Wrapper
PostPosted: Wed May 01, 2013 7:12 am 
Offline

Joined: Thu Apr 04, 2013 10:43 am
Posts: 3
@pTymN: Since typically only a very small portion of an app's code is performance critical, it's absolutely no problem to use Objective-C for the rest and use C/C++ but only where it actually makes a discernible (not just measurable) difference.

Also portability of ObjC is increasing, you can port apps (or have them ported) with Apportable and similar services rather easily, or you can use a native ObjC implementation for the target platform. I know one has been in development for Android, which means "the other half of the mobile market" is increasingly more accessible to ObjC developers. A few years down the road I expect there will be one or more ObjC engines that can natively build both iOS and Android apps.


Top
 Profile  
 
 Post subject: Re: Objective C Wrapper
PostPosted: Thu May 02, 2013 6:13 am 
Offline

Joined: Tue Sep 25, 2007 2:22 pm
Posts: 516
Good points, things are improving.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group