CCpickerView Screenshot


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


Comments (3)

3 Responses to “CCPickerView”

  1. Manuel says:

    hi, thanks for these tool,
    i have some kind of problem,
    how do i find wich row was selected?,
    i know there is a method pickerView didSelectRow,
    but its never reached.

  2. mick80234 says:

    There was a bug. I have fixed it and updated the code on github.

  3. Bozena says:

    Yo Trox tis Tris from the FFXI good old days , hope you’re okCame across this thguorh random link searching while I was looking at OSX iOS dev blogs.I’ve been a Mac person for a few years now, and, since I am unemployed right now (by choice its a long story lol) about six months ago I decided I would learn how to program the damn thingDecided to learn C to start off with programming is confusing enough without adding OOP to things but am looking to get into Obj-C iOS at some pointA couple of months back, I started using SFML, a simple Open GL wrapper. Ended up writing a game, just an Arkanoid clone, but quite a useful thing to do, as I learnt a hell of a lot from it.Am just fiddling round with tech demos at the moment, trying to work out what to do next. Looking at Cocos2D as well, but I think I need more experience before I try get my head round it.Hope you manage to get your game up and running, let me know if you need a beta tester lolLater manWayne

Leave a Reply

Powered by WordPress