标签:os io ar div sp line size on ad
Menu创建菜单:
Cocos2d-x下的菜单创建包括:
1.CCMenuItemFont 字体按钮创建
CCMenuItemFont * onlineVideo = MenuItemFont::create("Play online video", CC_CALLBACK_1(HelloWorld::menuOnlineVideoCallback, this));其中CC_CALLBACK_1代表其括号体里面为一回调函数,1代表参数个数;
onlineVideo->MenuItemFont::setFontSize(20);表示字体的大小;
2.CCMenuItemImage 图片按钮创建
顾名思义,按钮以图片的形式存在,点击后进入回调函数响应。
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));
3.CCMenuItemToggle 开关按钮创建
CCMenuItemToggle* itemWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...);
CCMenuItemToggle* item1 = CCMenuItemToggle::itemWithTarget(
this
,menu_selector(MenuLayer4::menuCallback),
CCMenuItemFont::itemFromString(
"On"
),
CCMenuItemFont::itemFromString(
"Off"
),NULL );
void HelloWorld::menuResourceVideoCallback(Ref* pSender)
{
if (_videoPlayer)
{
sprite->setOpacity(0);
_videoPlayer->setFileName("v.mp4");
_videoPlayer->play();
}
}
标签:os io ar div sp line size on ad
原文地址:http://www.cnblogs.com/cocos2014/p/3937656.html