Create a framed iPad version using cocos2D
I'm developing an iOS game using cocos2D. Because of budget constrains we don't have the resources to create a custom iPad version but we'd still like to offer iPad users a way to experience the game without having to upscale everything.
I'm therefore trying to take the following approach:
I've developed the game with iPhone4 in mind by creating -hd graphics and working in the point coordinate space of 320x480. I want to create the iPad开发者_StackOverflow社区 version by redefining the EAGLView so its boundary is (64, 32, 640, 960), designing a custom frame artwork that fills up the remaining space, loading the -hd graphics but keeping the point coordinate system to 320x480.
I've tried messing with contentScaleFactor and I've tried creating a custom base CCScene with scale = 2 but I find neither approach optimal. I know I could manually convert any position by device detection and a macro but I would preferably leave every coordinate as it is.
Is anyone familiar with the cocos2D source that could point me in the correct direction as with where I should modify the source to solve my problem?
You do a device check in the appdelagate and this is where you can specify to run specific things like higher res graphics or different code based on the platform.
It's not that hard to port an app to the iPad... if you use points and not pixels in your application code. There are several methods to use high res graphics for the iPhone 4 and the iPad. Sounds like you have the right approach if you have no budget for the iPad version.
For me the time to develop the iPad version of my game was six months. The iPhone version was 1 week. The code base is the same you just have to tweek some things like Retina displays and some graphics. But the majority of the code will not change.
Are you sure you don't want to make it for both? It's not that hard or costly! I would develop the iPad version first then scale down for the iPhone... It's easier to "Design Big" then scale down then it is to scale up... especially graphics! Just saying...
I think your best bet would be to go through your app and abstract out the positioning math for your iPhone game so that you can provide it for iPad and iPhone. For instance, if you've hardcoded positions in your code, replace them with variables, and either #define them with conditional compilation for iPad and iPhone, or compute them in init() from the screen extents. This would have the added benefit of making it easy to support any other new form factors that come out in the future (and is probably a good habit to get into anyway, since "magic numbers" is an anti-pattern that makes your code easy to break).
精彩评论