1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
//GameScene.h
#include"cocos2d.h"
class
GameScene:
public
cocos2d::Layer
{
:
static
cocos2d::Scene*createScene();
virtual
bool
init();
void
menuCallback(cocos2d::Ref*pSender);
CREATE_FUNC(GameScene);
};
|
//GameScene.cpp
#include"GameScene.h"
USING_NS_CC;
cocos2d::Scene*GameScene::createScene()
{
auto
scene=Scene::create();
//创建一个场景
layer=GameScene::create();
//创建一个图层
scene->addChild(layer);
return
scene;
}
//初始化当前的图层
GameScene::init()
{
return
false
;
//获取屏幕大小
SizevisibleSize=Director::getInstance()->getVisibleSize();
//autosize=Director::getInstance()->getWinSize();
sprite=Sprite::create(
"OnePiece_1.png"
);
sprite->setPosition(Vec2(visibleSize.width/2,visibleSize.height/2));
this
->addChild(sprite);
//创建菜单
//方法一
label=Label::createWithSystemFont(
"Jacedy"
,
"MarkerFelt"
item1->setPosition(Vec2(visibleSize.width*0.9,visibleSize.height*0.8));
//方法二
item2=MenuItemFont::create(
));
item2->setPosition(Vec2(visibleSize.width*0.9,visibleSize.height*0.7));
//方法三
sprite1=Sprite::create(
"btn-play-normal.png"
);
sprite2=Sprite::create(
"btn-play-selected.png"
);
item3=MenuItemSprite::create(sprite1,sprite2,monospace!important; border:0px!important; bottom:auto!important; float:none!important; height:auto!important; left:auto!important; line-height:1.1em!important; outline:0px!important; overflow:visible!important; position:static!important; right:auto!important; top:auto!important; vertical-align:baseline!important; width:auto!important; font-size:1em!important; min-height:inherit!important">));
item3->setPosition(Vec2(visibleSize.width*0.9,visibleSize.height*0.6));
//方法四
item4=MenuItemImage::create(
));
item4->setPosition(Vec2(visibleSize.width*0.9,visibleSize.width*0.5));
menu=Menu::create(item1,item2,item3,item4,NULL);
menu->setAnchorPoint(Vec2::ZERO);
menu->setPosition(Vec2::ZERO);
->addChild(menu);
true
;
}
GameScene::menuCallback(cocos2d::Ref*pSender)
{
}
|