Search code examples
androidcocos2d-iphonecocos2d-android

Scrollview in Cocos2d - android


How to Implement Scrolling functionality in cocos2d Surfaceview in android? Please give me some suggestion.


Solution

  • There is no scroll view available in cocos2d, but check the below details if it can help you.

    This example for screen reslution 320 x 480.

    1. Make one node with required height. Ex : My screen height is 320 and I made a node of height 640.
    2. Add it in the layer and set the position to (0, 320)
    3. in method CCTouchMoved() increase the node position as per user touch move value EX : CGPoint touchLocation = CCDirector.sharedDirector().convertToGL(CGPoint.ccp(event.getX(), event.getY())); node.setPosition(0, 320 + (touchLocation.y - touchlocation.y of touch began))

    Hope it will work for you and if any other details required then comment on this