Some classes ported to Cocos2d-X v2

Some classes ported to Cocos2d-X v2
0.0 0


I have ported some classes to Cocos2d-X v2:

It is working. tested i my personal projects.



Now i have a question.

I want use SlidingMenuGrid to make a menu like angrybirds:

How i can do it? I can use this class to do it?

My current code is:

float x = GameObjects::director~~>getWinSize.width / 2;
float y = GameObjects::director~~>getWinSize().height / 2;
CCArray *menuArray = new CCArray();
menu = new SlidingMenuGrid;
menu~~>initWithArray(menuArray, 2, 2, CCPoint(x, y), CCPoint(0, 0), false);



Now it is working. The problem is that when the sliding menu is add to screen, it start on top left instead of position that we pass as parameter to init function.

The menu only shows when you start/end drag first time, so i update the class to it start on correct place without animation. Before add it to screen we set position based on current page without bounce animation.


Thanks for SlidingMenu. I’ll try it


I have updated SlidingMenu class:

  • v1.3 20.06.2012 Paulo Coutinho - Changed method gotoPage to change page without animation, useful when menu is created.

It is useful because when you create the menu, it doesnt start the menu on correct place. So when you create the menu you call “gotoPage” to correct it.


CCArray menuArray = new CCArray;
menu = CCMenuItemImage::itemWithNormalImage(“stageBoxBackground1.png”, “stageBoxBackground2.png”, “stageBoxBackground3.png”, this, menu_selector(StageSelectScene::onMenuStartCallback));
menu = SlidingMenuGrid::menuWithArray(menuArray, 5, 2, CCPoint(95, 140), CCPoint(72, 100), false);
menu->gotoPage(0, false);

I dont changed the class too much, because this isn’t created by me, i only change two methods to bypass it.

I set position to 95/140 because i dont now how to centralize it on screen based on resolution. I dont what the logic for it or what width/height i need use to calculate correct position on the menu.