Cocos2d from iPad to iPhone

I currently have an iPad app built entirely on Cocos2D and Chipmunk. Now I want to transfer the application to the iPhone.

All I can find are tips on how to rebuild the iPad app. Is there a simple solution, such as zooming out your cocos2D scene?

Does anyone have any recommendations on this?

+4
source share
2 answers

Well, CCNode has a Scale property so you can do something like:

if(![MyApp isIPad]){ [myScene Scale:iPadToiPhoneScale]; } 

but you should not really do such things (not even sure if this will work).

In AppDelegate, you need to check whether you are working on an iPad or iPhone and downloading the correct resources (for example, previously reduced sprites).

Then, when creating your scenes instead of positioning your CCNodes in absolute positioning:

 [back setPosition:ccp(160, 240)]; 

put them in relative positioning:

 [back setPosition:ccp(0.5*[MyApp deviceWidth], 0.5*[MyApp deviceHeight])]; 

where MyApp will have a bunch of static helpers that will bring back device capabilities.

Even better, why not something like:

 CGPoint convertedPosition = [MyApp convertForDevice:ccp(160, 240)]; [back setPosition:convertedPosition]; 

Hope this helps.

+2
source

Sheesh ... This is actually not the "answer", but I will say that I had to do this type of conversion once - and one thing that helped me was that you could "change" the XIB file from the "iPhone "on the" iPad "one back and forth while editing XML. I think this is a change issue:

archive type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB"

to

<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB"

(But I don’t remember exactly).

0
source

All Articles