cocos2dx学习日记三:menu创建

前端之家收集整理的这篇文章主要介绍了cocos2dx学习日记三:menu创建前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
首先是最熟悉的helloworld自带的创建
   auto closeItem = MenuItemImage::create(
                                           "CloseNormal.png","CloseSelected.png",CC_CALLBACK_1(HelloWorld::menuCloseCallback,this));
    
	closeItem->setPosition(Vec2(origin.x + visibleSize.width - closeItem->getContentSize().width/2,origin.y + closeItem->getContentSize().height/2));
    
	auto menu = Menu::create(closeItem,NULL);

	menu->setPosition(Vec2::ZERO);

	this->addChild(menu,1);

MenuItemLabel创建

	auto start_game = MenuItemLabel::create(
					        Label::createWithTTF("StartGame","fonts/Marker Felt.ttf",30),this,menu_selector(HelloWorld::menuCloseCallback));
	
	auto start_menu = Menu::create(start_game,NULL);
	
	this->addChild(start_menu);

MenuItemFont创建

	auto new_game = MenuItemFont::create("NewGame",menu_selector(HelloWorld::menuCloseCallback));

	auto game_menu = Menu::create(new_game,NULL);

	new_game->setPosition(visibleSize.width / 4,visibleSize.height / 2);

	this->addChild(new_game);

MenuItemSprite创建

	auto sprite_menu = MenuItemSprite::create(
		                                  Sprite::create("ButtonStar.png"),Sprite::create("ButtonStarSel.png"),this));

	auto menu_star = Menu::create(sprite_menu,NULL);

	menu_star->setPosition(visibleSize.width / 8,visibleSize.height / 2);

	this->addChild(menu_star);



原文链接:https://www.f2er.com/cocos2dx/344484.html

猜你在找的Cocos2d-x相关文章