Cocos2d 之FlyBird开发---GameAbout类
2024-09-05 11:09:22
| 版权声明:本文为博主原创文章,未经博主允许不得转载。(笔者才疏学浅,如有错误,请多多指教)
一般像游戏关于的这种界面中,主要显示的是游戏的玩法等。
GameAbout.h
#ifndef _GAME_ABOUT_H_
#define _GAME_ABOUT_H_ //////////////////////////////////////////////////////////
//////// 此文件主要描述关于界面 #include "cocos2d.h"
USING_NS_CC; class GameAbout : public cocos2d::Layer
{
private:
cocos2d::MenuItemImage* awayItem;
cocos2d::Sprite* background;
public:
static cocos2d::Scene* createScene();
virtual bool init();
void aboutInterface();
void goMainInterface(cocos2d::Ref*);
CREATE_FUNC(GameAbout);
};
#endif // _GAME_ABOUT_H_
GameAbout.cpp
#include "GameAbout.h"
#include "GameUnit.h"
#include "MainMenu.h" unit u1; cocos2d::Scene* GameAbout::createScene()
{
auto scene = Scene::create();
auto layer = GameAbout::create();
scene->addChild(layer);
return scene;
} bool GameAbout::init()
{
if (!Layer::init())
{
return false;
} this->aboutInterface(); //best->setColor(Color3B(0, 0, 0));
//best->setString(__String::createWithFormat("%d", Score - 1)->getCString()); return true;
} void GameAbout::aboutInterface()
{
background = Sprite::create("background/about.png");
background->setPosition(Vec2(u1.winOrigin().x + u1.winSize().width / 2,
u1.winOrigin().y + u1.winSize().height / 2));
background->setScale(u1.scaleX(background, u1.winSize()),
u1.scaleY(background, u1.winSize()));
this->addChild(background, 0); awayItem = MenuItemImage::create(
"button/away.png",
"button/buttom.png",
CC_CALLBACK_1(GameAbout::goMainInterface, this));
awayItem->setPosition(Vec2(u1.winOrigin().x + awayItem->getContentSize().width / 2,
u1.winOrigin().y + awayItem->getContentSize().height / 2));
auto m = Menu::create(awayItem, NULL);
m->setPosition(Vec2::ZERO);
this->addChild(m, 2);
} void GameAbout::goMainInterface(cocos2d::Ref* pSender)
{
Director::getInstance()->replaceScene(TransitionFadeBL::create(1,
MainMenu::createScene()));
}
函数的功能介绍详见:http://lipei95.blog.163.com/blog/static/257578646201671924726318/
效果图:
最新文章
- [python] 安装numpy+scipy+matlotlib+scikit-learn及问题解决
- AngularJS 模块
- 控件(弹出类): FlyoutBase, Flyout, MenuFlyout
- Codeforces Round #373 (Div. 2) B
- golang操作文件的四种方法
- WPF:行列显示
- photoshop,用切片工具等分图片
- rfid门禁系统笔记
- web相关
- easyui datagrid pagesize设置无效
- 【HDOJ】1438 钥匙计数之一
- SVN仓库迁移到Git遇到的两个问题和解决办法
- 003_JS基础_面向对象基础
- Spring Data与elasticsearch版本对应关系
- SQL Server数据库————模糊查询和聚合函数
- ionic3 百度地图插件定位 问题
- css 样式表的书写顺序
- linux下的初始化系统systemd简科普
- 软件测试中Bug的生命周期以及Bug的严重等级
- 使用MyEclipse开发Java EE应用:用XDoclet创建EJB 2 Session Bean项目(一)