카테고리 없음
스크롤 구현하기 Scrolling function in cocos2d for android
커널제로
2012. 11. 29. 14:35
http://stackoverflow.com/questions/11316224/scrollview-in-cocos2d-android
|
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 |
|
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. |