http://stackoverflow.com/questions/11316224/scrollview-in-cocos2d-android

 

1down voteaccepted

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

 

 

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.

Posted by 커널제로

본 블로그는 페이스북 댓글을 지원합니다.

,