【Cocos2d-x 3.0学习笔记】菜单的进入和退出

//菜单的弹出代码如下:
	Size size = Director::sharedDirector()->getWinSize();  
	Menu* menu = Menu::create(item0, item1, item2, item3, NULL);  
	menu->alignItemsVerticallyWithPadding(5.0f);  
	menu->setPosition(ccp(size.width/2.0f, size.height));  
	menu->setTag(menu_pause_tag);  
	this->addChild(menu, 5);  
	menu->runAction(MoveTo::create(0.5f, ccp(size.width / 2.0f, size.height / 2.0f))); 

	//菜单的收起代码如下:
	Size size = Director::sharedDirector()->getWinSize();  
	Menu* menu = (Menu*)this->getChildByTag(menu_pause_tag);  
	Point point = ccp(size.width / 2.0f, size.height + menu->getContentSize().height / 2.0f);  
	MoveTo* move = MoveTo::create(0.5f, point);  
	menu->runAction(move);  

	//由快到慢:弹出菜单的代码如下:
	Menu* menu = Menu::create(item0, item1, item2, item3, NULL);  
	menu->alignItemsVerticallyWithPadding(5.0f);  
	menu->setPosition(ccp(size.width/2, size.height));  
	menu->setTag(menu_pause_tag);  
	this->addChild(menu, 5);  
	MoveTo* move = MoveTo::create(0.5f, ccp(size.width/2, size.height/2));  
	Action* action = EaseExponentialOut::create(move);    
	menu->runAction(action);

	//先慢后快:收起菜单的代码如下:
	Size size = Director::sharedDirector()->getWinSize();  
	Menu* menu = (Menu*)this->getChildByTag(menu_pause_tag);  
	Point point = ccp(size.width/2, size.height + menu->getContentSize().height/2);  
	MoveTo* move = MoveTo::create(0.5f, point);  
	Action* action = EaseExponentialIn::create(move);  
	menu->runAction(action); 

你可能感兴趣的:(cocos2d-x,菜单的进入和退出)