Search code examples
androidcocos2d-iphonepanelcocos2d-androidandroid-sliding

How to add panels in android using cocos2d


I want to add a sliding panel view using cocos2d for android. Any suggestions.


Solution

  • The way i've achieved this in one of my previous android market apps for paintball field designing is to have a separate CCLayer class added as a child to the main scene, and have the main scene responding to the CCTouchesBegan. if the location of the touch is within the co-ords of the visible panel, then call a 'touched' method inside it passing the touch co-ords, so that it can deal with it's own content.

    On another panel at the bottom I had a button, which showed or hid the side panel, so it didn't 'slide' or support being 'flung' across the screen, but rather was shown or hidden.

    Sliding it or flinging it on/off the screen could be written relatively simply i believe, using a combination of CCTouchesMoved and CCTouchesEnded to track the slide/fling and perform translation on the layer co-ords.

    There's nothing to have prevented me implementing a slide in/out using some simple animation, but I had no requirement for it in the app, and hence didn't implement it.

    Hope this is at least of some use,sorry i can't provide some worked examples right now, busy with work.