How can I create a scrollmenu..

英文不好 随便说啦
I want to create a menu like this:
http://www.cocoachina.com/bbs/read.php?tid-74678.html
How can I do it?
Thx.


11.JPG (7.0 KB)

刚发现 这是我同学的账号,,恩 我们一起在用cocos2d-x做项目。。

看看Test工程的代码,刚进入就是一个可以上下拖拽的菜单

Harrison Xi wrote:

看看Test工程的代码,刚进入就是一个可以上下拖拽的菜单

不过,这不是我说的这种效果吧,我现在的slot也都能拖动,但是我想让它的显示范围限制在menu上。

Perhaps you can do the job in MyLayer::ccTouchesMoved(…), call sprite->setPosition to move the items.

Walzer Wang wrote:

Perhaps you can do the job in MyLayer::ccTouchesMoved(…), call sprite->setPosition to move the items.

yes,I have already moved the slot like this,but when the slot outofthe bound of the menu,how can I hide it(do not ues setvisible=false).

I found your demo “DepthEffect”,you override the CCSprite::draw(), I follow this way,in the draw function I use glClipPlanef to clip the sprite‘s size,and it is success.
but,I cannot override CCLayer::draw() like this, because I want to clip the layer’s size,so when the slot outof the layer,it can be hide.

哎呀,英文真费劲,就是说 我想在scene上加一个menu层,它的大小可以设置
滑动的效果像这里http://www.cocos2d-iphone.org/archives/943的那种样子。

不知道清楚不。。

CCSprite::setTextureRect; just can limit the display area. you can create one large white sprite as menu`s background, then sprite::setTextureRect, then menu is added in back sprite, then all menu item are added in menu, ok, just have a try , come on !

CCSprite::setTextureRect; just can limit the display area. you can create one large white sprite as menu`s background, then sprite::setTextureRect, then menu is added in background sprite, then all menu item are added in menu, ok, just have a try , come on !

奇 洛 wrote:

CCSprite::setTextureRect; just can limit the display area. you can create one large white sprite as menu`s background, then sprite::setTextureRect, then menu is added in background sprite, then all menu item are added in menu, ok, just have a try , come on !

Thank you!
but use CCSprite::setTextureRect is not a good way,and the children item still can out of the menu.

I use this way,override the visit() like this:

class ClipSprite : public CCSprite
{
public:
    virtual void visit()
    {
          glEnable(GL_SCISSOR_TEST);
          glScissor(x,y,width,height);//
          CCSprite::visit();
          glDisable(GL_SCISSOR_TEST);
    }
    ......
};

learn more about it at this page
http://blog.sina.com.cn/s/blog_7f2cb66b0100tihq.html

I use the glsissor to cut the draw rect but this display effect is different between android and ios . so i give up it. and now i use picture to cover unvisable rect

This article was so helpful to me to implement a kind of partially view node.
I was thinking like Tao that glScissor behaves differently in Android and iOS but it was mistake. In Android, its viewport are stretched to fit the screen. A point being used in game logic would be different with the real screen point being used in openGL. So the points need to be converted into real screen point. Following code of setScissorInPoints() in CCEGLView_android.cpp can be used for the conversion.
@
float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR();
glScissor((GLint)(x * factor) + m_rcViewPort.origin.x,
(GLint)(y * factor) + m_rcViewPort.origin.y,
(GLint)(w * factor),
(GLint)(h * factor));
@