Posts Tagged ‘cocos2d’

Integrating Cocos2d V1 and Storyboards

Wednesday, May 30th, 2012

I have read quite a few tutorials on integrating Cocos2d and UIKit, unfortunately when you rotated the  iPhone they would not display correctly.  I needed to have portrait UIKit views for settings and  landscape Cocos2d views for the “game”. While trying to figure out how to fix this issue I ended up finding my own solution.  You can read about it here.

CCPickerView

Tuesday, May 22nd, 2012
CCpickerView Screenshot

CCpickerView

I have had a few weeks of being able to work on my Math Explosion App, which is in serious need of an update. It was the first app that wrote way back in 2009 and has not been updated since then.  I always keep expecting it to break when Apple releases a new version of iOS.  I am doing more than an update, I am doing a complete rewrite. The original app was written using UIKit and Core Animation but I have felt for a very long time that the app needs to be more gamey to get the kids more interested in playing. As a result I am doing a complete rewrite using Cocos2d. I have dabbled with Cocos2d in the past but have never been able to spend much time using it until now. One of the first things I missed from UIKit was the UIPickerView. I also noticed quite a few other people out there also looking for a UIPickerView equivalent but with no success. In the end I wrote my own CCPickerView with the desire to make it as similar as UIPickerView, but for Cocos2d.  If you know how to use UIPickerView you will have no problem finding your way around setting up CCPickerView.

I want to mention some of the differences.  Firstly CCPickerView does not create a picker like UIPickerView. It simply creates the components, you have to supply your own “overlay”. I did this deliberately for two reasons. Firstly it was way simpler for me to code and secondly I figured everyone would want to have their own picker image that matched their app.  The CCPickerView can be as big or as small as you like, which is not true for UIPickerView unless you incorporate some tricks.

I also added some extras like continuous components.  With UIPickerView you add your rows, but if you want the last row to appear to be next to the first row as if the component has been rotated through 360 degrees you had to do the extra coding yourself.  I also needed the components to spin.  This was a bit tricky for me as I wanted something that was flexible as I could see many possible uses.  As a result you can configure settings like the speed of the spin, how many times the components spin and if the components ease in and out when starting and stopping.  You also get to control the stop row.  How else are you going to have a winner.

You can find the code on GitHub  https://github.com/fidgetware/CCPickerView