Vitaly Shumakov Slider Menu Grid
Posts 23
Added by Vitaly Shumakov about 1 year ago

Hello!
I copied the source code ported from cocos2D for iphone (http://brandonreynolds.com/blog/2011/01/09/cocos2d-sliding-menu-grid/), based on the source code on thread page K pop(http://www.cocos2d-x.org/boards/6/topics/9803). I corrected several errors and added a few features (tags for each page)

SlidingMenu.zip (3.4 kB)

SlidigMenu.zip (3.8 kB)

Emmy Chen RE: Slider Menu Grid
Posts 42
Added by Emmy Chen about 1 year ago

wow. this is what I am looking for. got to try it out.

thanks

Vitaly Shumakov RE: Slider Menu Grid
Posts 23
Added by Vitaly Shumakov about 1 year ago

I hope you find useful, Emmy :)

New version! I corrected some errors and changed the logic of adding elements of the array. The first items are added to the first page

Emmy Chen RE: Slider Menu Grid
Posts 42
Added by Emmy Chen about 1 year ago

Hi Vitaly Shumakov:

I tried Slider Menu Grid. It works very well. Thank you very much providing this wonderful code. I am wondering can you make it as a loop? if I slide menu to the last page if I continue slide the page , can you make it go to first page. same as the first page, if I continue slide the screen, can you make it go to the last page?

Thanks again

Emmy

Vitaly Shumakov RE: Slider Menu Grid
Posts 23
Added by Vitaly Shumakov about 1 year ago

The fact is that at the moment, the transition is carried out using the following code:


void SlidingMenuGrid::moveToCurrentPage()
{
    CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    // Perform the action
    CCEaseBounce* action =CCEaseBounce::actionWithAction(CCMoveTo::actionWithDuration(fAnimSpeed*0.3f, GetPositionOfCurrentPage()));
    runAction(action);
}

If you simply navigate around the pages, then this code will scroll through all the pages are located between the first and last pages. To loop, I need to change the whole scheme of this piece of software. Of course, I think, but nothing yet I promise.

K pop RE: Slider Menu Grid
Posts 21
Location S.korea
Added by K pop about 1 year ago

i fixed it :) buildGrid buildGridVertical

void SlidingMenuGrid::buildGrid(int cols, int rows) {
CCSize winSize = CCDirector::sharedDirector()->getWinSize();

int col = 0, row = 0;
CCArray* child = this->getChildren();
CCObject* item;
CCARRAY_FOREACH(child, item) {
CCMenuItemSprite* getItem = (CCMenuItemSprite*) item;
getItem->setPosition(ccp(this->getPosition().x + col * padding.x + (iPageCount * winSize.width), this->getPosition().y - row * padding.y));
// getItem->setPosition(ccp(this->getPosition().x+winSize.width/2,-winSize.height/2));
++col;
if (col == cols) {
col = 0;
++row;
if( row == rows )
{
iPageCount++;
CCLog("iPageCount: %d",iPageCount);
col = 0;
row = 0;
}
}
}
if(child->count() > rows*cols*iPageCount)   <-- add code for FIX
{
iPageCount++;+
}

}

  1. example
    there is horisontal menugrid of cols 5 rows 2
    allItem count is 22

1 2 3 4 5 11 12 13 14 15 21 22
6 7 8 9 10 16 17 18 19 20

in previous code iPageCount is 2 (must be 3)

so i fix this bug have nice day :) if you use my SlidingMenuGrid please add my Nickname by comment haha

Vitaly Shumakov RE: Slider Menu Grid
Posts 23
Added by Vitaly Shumakov about 1 year ago

Fixed a bug where a locked item indicated by the touch as the chosen.
Fixed a bug page counter by Mr. K pop (previous message)
Added the ability to be used as a descriptor page of any object pointer CCNode *
P.S. Mr. K pop, your nickname add everywhere in the code ;)

SlidingMenu (v1.2).zip - Fix a bugs (4 kB)

Emmy Chen RE: Slider Menu Grid
Posts 42
Added by Emmy Chen about 1 year ago

Thanks for the bug fixing. Good job. I had to work around with this bug. I am so happy that it got fixed.

Vitaly Shumakov RE: Slider Menu Grid
Posts 23
Added by Vitaly Shumakov about 1 year ago

Excellent, Emmy :)

Paulo Coutinho RE: Slider Menu Grid
Posts 77
Added by Paulo Coutinho 11 months ago

Hi,

How to use it?

Chris Harback RE: Slider Menu Grid
Posts 16
Added by Chris Harback 10 months ago

I was super excited to see this class out here, since I think it is pretty close in function to Cocos2d-extension-iPhone's CCScrollLayer. Thanks Vitaly Shumakov for writing it!

Sadly, it looks like I'm going to have to adjust for the changes in the latest build of Cocos2d-x 2.0 (no more CCMutableArray, etc.).

Has anybody started on such an adjustment? I had thought at first it would be pretty straightforward but as I've gone on with it it looks more complicated than I had expected.

Paulo Coutinho RE: Slider Menu Grid
Posts 77
Added by Paulo Coutinho 10 months ago

Already have SliderMenu converted to Cocos2d-2.0:

https://github.com/prsolucoes/cocos2d-x

Chris Harback RE: Slider Menu Grid
Posts 16
Added by Chris Harback 10 months ago

Paulo Coutinho wrote:

Already have SliderMenu converted to Cocos2d-2.0:

https://github.com/prsolucoes/cocos2d-x

Incredible! Thanks Paulo Coutinho!

Dean Nahaul RE: Slider Menu Grid
Posts 14
Location England
Added by Dean Nahaul 7 months ago

Hi all,

I'm trying to use this sliding menu for my game and everything is working great. The only problem is that i cannot let the program know which button in the grid has been pressed. e.g If level 4 has been selected i'd like a function to return the value 4.

I'm trying to use the getTag() function but it always seems to return "-1"

Any suggestions?

@void LevelMenu::menuLevels(CCObject* pSender) {
CCScene* levelSelect = HelloWorld::scene();

gameConfig.levelSelected = slidingMenu->getTag();  // not working :(
CCMenuItem test1 = slidingMenu->getSelectedItem(); //just trying to find the id
CCDirector::sharedDirector()->replaceScene(CCTransitionFade::transitionWithDuration(1.0f,levelSelect));

}@

Vitaly Shumakov RE: Slider Menu Grid
Posts 23
Added by Vitaly Shumakov 7 months ago

Hi Dean!
Before using getTag () you have to set the ID of the tag using the setTag (). -1 means that the identifier for this menu item is not set.

Dean Nahaul RE: Slider Menu Grid
Posts 14
Location England
Added by Dean Nahaul 7 months ago

Thank you very much for the quick reply Vitaly, it's worked a treat! :D

Emilio Exposito RE: Slider Menu Grid
Posts 37
Added by Emilio Exposito 5 months ago

Hi,

Has someone used this sliding menu in cocos2d-2.0-x-2.0.4? I was able to show in the screen, it slides between pages but when a menu item is clicked the callback function is not called. I was debugging the code and I found that the "error" (I do not know if it is an error or something that I am not doing right) is in SlidingMenuGrid::GetItemWithinTouch method, the local ccpoint and the rect generated do not match...

Do you have also this error?

Thank you for your answers!!!

Paulo Coutinho RE: Slider Menu Grid
Posts 77
Added by Paulo Coutinho 21 days ago

Hi,

I need it to last cocos2d-x version, anyone have it working with last version?

Thanks.


(1-17/17)