How to Implement Scrolling functionality in cocos2d Surfaceview in android? Please give me some suggestion.
Asked
Active
Viewed 1,307 times
1
-
scrollview available on cocos2d android1, you test scorllview functionailty also there. https://github.com/ZhouWeikuan/cocos2d/blob/master/cocos2d-android/src/org/cocos2d/extensions/scroll/CCScrollView.java – MuthusamyBose Aug 23 '12 at 06:29
2 Answers
3
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.
- Make one node with required height. Ex : My screen height is 320 and I made a node of height 640.
- Add it in the layer and set the position to (0, 320)
- 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

Ajit
- 214
- 1
- 6
1
You can direct add android ui scrollview in cocos2d-android 1 like that
Activity mActivity=CCDirector.sharedDirector().getActivity();
View view=(LinearLayout) LayoutInflater.from(mActivity).inflate(R.layout.level_scroll,null);
mActivity.runOnUiThread(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
mActivity.addContentView(view, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
}
});
You can make level_scroll.xml as per your requirement.

Kalpesh
- 1,767
- 19
- 29