stick hero 安卓有没有外挂

本文是依据文章所完成的
直接来代码:
AppDelegate.h
_APP_DELEGATE_H_
_APP_DELEGATE_H_
4 #include "cocos2d.h"
The cocos2d Application.
9 The reason for implement as private inheritance is to hide some interface call by Director.
AppDelegate : private cocos2d::Application
13 public:
AppDelegate();
virtual ~AppDelegate();
Implement Director and Scene init code here.
@return true
Initialize success, app continue.
@return false
Initialize failed, app terminate.
virtual bool applicationDidFinishLaunching();
The function be called when the application enter background
the pointer of the application
virtual void applicationDidEnterBackground();
The function be called when the application enter foreground
the pointer of the application
virtual void applicationWillEnterForeground();
37 #endif // _APP_DELEGATE_H_
AppDelegate.cpp
1 #include "AppDelegate.h"
2 #include "HelloWorldScene.h"
3 #include "WelcomeScene.h"
5 USING_NS_CC;
7 AppDelegate::AppDelegate() {
11 AppDelegate::~AppDelegate()
15 bool AppDelegate::applicationDidFinishLaunching() {
// initialize director
auto director = Director::getInstance();
auto glview = director-&getOpenGLView();
if(!glview) {
glview = GLView::create("My Game");
director-&setOpenGLView(glview);
// 添加设计分辨率适配,参数,(设计分辨率的宽度,高度,分辨率适配的方式)
glview-&setDesignResolutionSize(1080, 1980, ResolutionPolicy::FIXED_WIDTH);
// turn on display FPS
director-&setDisplayStats(true);
// set FPS. the default value is 1.0/60 if you don't call this
director-&setAnimationInterval(1.0 / 60);
// create a scene. it's an autorelease object
//auto scene = HelloWorld::createScene();
auto scene = WelcomeScene::create();
director-&runWithScene(scene);
return true;
43 // This function will be called when the app is inactive. When comes a phone call,it's be invoked too
44 void AppDelegate::applicationDidEnterBackground() {
Director::getInstance()-&stopAnimation();
// if you use SimpleAudioEngine, it must be pause
// SimpleAudioEngine::getInstance()-&pauseBackgroundMusic();
51 // this function will be called when the app is active again
52 void AppDelegate::applicationWillEnterForeground() {
Director::getInstance()-&startAnimation();
// if you use SimpleAudioEngine, it must resume here
// SimpleAudioEngine::getInstance()-&resumeBackgroundMusic();
Resource.h
1 #ifndef __Resource_H__
2 #define __Resource_H__
4 // 游戏欢迎界面 (WelcomScene) 时的背景图片
5 #define welcome_background_image0 "image/bg/bg1.jpg"
6 #define welcome_background_image1 "image/bg/bg2.jpg"
7 #define welcome_background_image2 "image/bg/bg3.jpg"
8 #define welcome_background_image3 "image/bg/bg4.jpg"
9 #define welcome_background_image4 "image/bg/bg5.jpg"
11 // 游戏欢迎界面 (WelcomeScene) 的标题图片
12 #define welcome_title_image "image/uires_1.png"
14 // 游戏欢迎界面 (WelcomeScene) 的开始菜单图片
15 #define welcome_start_image "image/uires_2.png"
17 // 游戏欢迎界面 (WelcomeScene) 的平台图片
18 #define welcome_floor_image "image/stage1.png"
20 // 游戏人物 Hero 的图片
21 #define hero1 "image/anim1/stay1.png"
23 // 棍子 stick 的图片
24 #define stick_image "image/stick1.png"
27 #endif __Resource_H__
WelcomeScene.h
1 #ifndef __Welcome_Scene_H__
2 #define __Welcome_Scene_H__
4 #include "cocos2d.h"
6 USING_NS_CC;
8 class WelcomeScene :public Scene{
10 public:
WelcomeScene();
~WelcomeScene();
virtual bool init();
CREATE_FUNC(WelcomeScene);
23 #endif __Welcome_Scene_H__
WelcomeScene.cpp
1 #include "WelcomeScene.h"
2 #include "BackgroundLayer.h"
3 #include "Resource.h"
5 WelcomeScene::WelcomeScene(){
9 WelcomeScene::~WelcomeScene(){
13 bool WelcomeScene::init(){
if (!Scene::init()){
return false;
Size visibleSize = Director::getInstance()-&getVisibleSize();
BackgroundLayer* _backgroundLayer = BackgroundLayer::create();
this-&addChild(_backgroundLayer, 1, 1);
return true;
BackgroundLayer.h
1 #ifndef __Background_Layer_H__
2 #define __Background_Layer_H__
4 #include "cocos2d.h"
5 #include "Resource.h"
6 #include "Player.h"
7 #include "GameOverLayer.h"
9 USING_NS_CC;
11 class BackgroundLayer :public Layer{
13 public:
BackgroundLayer();
~BackgroundLayer();
virtual bool init();
CREATE_FUNC(BackgroundLayer);
void BGImageMove(float);
// 开始菜单按钮的回调函数
void start(Ref *pSender);
void addStage();
void stageMove();
// 单点触摸事件回调函数
virtual bool onTouchBegan(Touch *touch, Event *unused_event);
virtual void onTouchMoved(Touch *touch, Event *unused_event);
virtual void onTouchEnded(Touch *touch, Event *unused_event);
// 将棍子添加到视线中
void addStick();
// 将棍子加长
void stickLength(float);
void stopStick();
// 旋转棍子
void rotateStickAndGo();
void stageAndPlayerMove();
void resetStick();
void initStick();
void playerMoveToNextStage();
void PlayerDown();
void PlayerMove();
56 private:
// 可视区域大小
Size visibleS
Sprite* _imageO
Sprite* _imageT
// 开始按钮菜单
MenuItemSprite* _startB
Sprite* _gameT
// 英雄所站的平台
Sprite *stage_sprite[3];
// 存储平台数据
int stage_
// 标识,为了方便计算
// 单点触摸事件
EventListenerTouchOneByOne *_touchL
// 简单的状态机
// 存储我们棍子的长度
float touchL
Vec2 stickP
GameOverLayer*
float destLengthM
float destLengthM
102 #endif __Background_Layer_H__
BackgroundLayer.cpp
1 #include "BackgroundLayer.h"
4 BackgroundLayer::BackgroundLayer():
5 stage_number(1),
6 isStart(false),
7 lastStage(2),
8 nowStage(0),
9 nextStage(1){
13 BackgroundLayer::~BackgroundLayer(){
17 bool BackgroundLayer::init(){
if (!Layer::init()){
return false;
visibleSize = Director::getInstance()-&getVisibleSize();
/*****************
背景图片随机显示
***************/
// 随机生成 5 种背景图片
srand(time(0));
// 随机生成数种子
int _bgImageNumber = rand() % 5;
log("%d", _bgImageNumber);
switch (_bgImageNumber){
_imageOne = Sprite::create(welcome_background_image0);
_imageTwo = Sprite::create(welcome_background_image0);
_imageOne = Sprite::create(welcome_background_image1);
_imageTwo = Sprite::create(welcome_background_image1);
_imageOne = Sprite::create(welcome_background_image2);
_imageTwo = Sprite::create(welcome_background_image2);
_imageOne = Sprite::create(welcome_background_image3);
_imageTwo = Sprite::create(welcome_background_image3);
_imageOne = Sprite::create(welcome_background_image4);
_imageTwo = Sprite::create(welcome_background_image4);
_imageOne-&setPosition(visibleSize.width / 2, visibleSize.height / 2);
_imageTwo-&setPosition(visibleSize.width / 2 + _imageTwo-&getContentSize().width, visibleSize.height / 2);
this-&addChild(_imageOne, 1);
this-&addChild(_imageTwo, 1);
/*****************
背景图片随机显示
***************/
/*****************
***************/
_gameTitle = Sprite::create(welcome_title_image);
_gameTitle-&setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 5 * 4));
this-&addChild(_gameTitle, 2);
/*****************
***************/
/*****************
添加开始按钮
***************/
_startButton = MenuItemSprite::create(Sprite::create(welcome_start_image), Sprite::create(welcome_start_image), NULL, this, menu_selector(BackgroundLayer::start));
_startButton-&setPosition(Vec2(visibleSize.width / 2, visibleSize.height / 2 + 10));
// 按钮上下来回移动的效果
MoveTo *startButtonMoveDown = MoveTo::create(2.0f, Vec2(visibleSize.width / 2, visibleSize.height / 2 - 20));
MoveTo *startButtonMoveUp = MoveTo::create(2.0f, Vec2(visibleSize.width / 2, visibleSize.height / 2 + 20));
Sequence *startButtonSequence = Sequence::create(startButtonMoveDown, startButtonMoveUp, nullptr);
RepeatForever *startButtonRepeatForever = RepeatForever::create(startButtonSequence);
_startButton-&runAction(startButtonRepeatForever);
_menu = Menu::create(_startButton, nullptr);
_menu-&setPosition(Vec2::ZERO);
this-&addChild(_menu, 2);
/*****************
添加开始按钮
***************/
/*****************
添加英雄所站的平台
***************/
// 对所有平台进行一次初始化,
// 并且把第一个平台显示在屏幕中心
for (int i = 0; i & 3; i++){
stage_sprite[i] = Sprite::create(welcome_floor_image);
// 在 x轴 方向扩大30倍
stage_sprite[0]-&setScaleX(30);
// 设置另两个平台的位置
for (int i = 1; i & 3; i++){
stage_sprite[i]-&setPosition(Vec2(visibleSize.width + stage_sprite[i]-&getScaleX() * stage_sprite[i]-&getContentSize().width, stage_sprite[i]-&getContentSize().height / 2));
stage_sprite[0]-&setPosition(Vec2(visibleSize.width / 2, stage_sprite[0]-&getContentSize().height / 4));
for (int i = 0; i & 3; i++){
this-&addChild(stage_sprite[i], 3);
/*****************
添加英雄所站的平台
***************/
/*****************
单点触摸事件
***************/
_touchListener = EventListenerTouchOneByOne::create();
_touchListener-&setSwallowTouches(true);
// true 表示不向下传递触摸事件
_touchListener-&onTouchBegan = CC_CALLBACK_2(BackgroundLayer::onTouchBegan, this);
_touchListener-&onTouchMoved = CC_CALLBACK_2(BackgroundLayer::onTouchMoved, this);
_touchListener-&onTouchEnded = CC_CALLBACK_2(BackgroundLayer::onTouchEnded, this);
_eventDispatcher-&addEventListenerWithSceneGraphPriority(_touchListener, this);
/*****************
单点触摸事件
***************/
/*****************
***************/
//// 初始化主角
//_player.init();
//// 先获取到我们Player对象中的Sprite对象,然后在对Sprite对象进行坐标设置。设置的位置是在我们平台之上
//_player.getSprite()-&setPosition(Vec2(visibleSize.width / 2, stage_sprite[0]-&getContentSize().height / 4 * 3));
//// 将我们Player对象中的Sprite对象加入到场景中
//this-&addChild(_player.getSprite(), 10);
_player.init();
_player.setPosition(Vec2(visibleSize.width / 2, stage_sprite[0]-&getContentSize().height / 4 * 3));
this-&addChild(_player.getSprite(), 5);
_player.stay();
/*****************
***************/
/*****************
***************/
_stick = Sprite::create(stick_image);
// 这里我们先把锚点设置为图片的正下方,这样我们也方便我们设置它的位置
_stick-&setAnchorPoint(Vec2(0.5, 0));
// 在我们不需要用到这个棍子的时候,我们先把它设置在屏幕外面
_stick-&setPosition(Vec2(-_stick-&getContentSize().width, -_stick-&getContentSize().height));
this-&addChild(_stick, 15);
/*****************
***************/
return true;
164 void BackgroundLayer::BGImageMove(float){
168 void BackgroundLayer::start(Ref *pSender){
// 设置动画,标题和按钮向上飞出屏幕,平台移动到指定位置
MoveTo *menuMove = MoveTo::create(0.8f, Vec2(visibleSize.width / 2, visibleSize.height + _menu-&getContentSize().height));
MoveTo *gameTitleMove = MoveTo::create(0.8f, Vec2(visibleSize.width / 2, visibleSize.height + _gameTitle-&getContentSize().height));
_menu-&runAction(menuMove);
_gameTitle-&runAction(gameTitleMove);
MoveTo *gamefloor = MoveTo::create(1.0f, Vec2(100, stage_sprite[0]-&getContentSize().height / 4));
stage_sprite[0]-&runAction(Sequence::create(gamefloor, CallFunc::create([this](){
// 移除按钮
this-&removeChild(_menu);
log("remove menu");
// 移除标题
this-&removeChild(_gameTitle);
log("remove gametitle");
}),nullptr));
addStage();
isStart = true;
_player.start(Vec2(100, stage_sprite[0]-&getContentSize().height / 4 * 3));
189 void BackgroundLayer::stageMove(){
/***********************************************
* 开始的三行代码是用来得到当前对应的平台编号和前后平台的编号,
* 这里一定要注意我们自己的编号是[1,3],而数组的编号是[0,2],注意逻辑关系
*************************************************/
nowStage = stage_number == 0 ? 2 : stage_number - 1;
lastStage = nowStage == 0 ? 2 : (nowStage - 1);
nextStage = nowStage == 2 ? 0 : (nowStage + 1);
MoveTo *nowStageMove = MoveTo::create(1.0f, Vec2(100, stage_sprite[0]-&getContentSize().height / 4));
stage_sprite[nowStage]-&runAction(nowStageMove);
MoveTo *lastStageMove = MoveTo::create(1.0f, Vec2(-stage_sprite[lastStage]-&getContentSize().width * stage_sprite[lastStage]-&getScaleX(), stage_sprite[0]-&getContentSize().height / 4));
stage_sprite[lastStage]-&runAction(lastStageMove);
addStage();
initStick();
210 void BackgroundLayer::addStage(){
/*****************************************************
* setScale 并不会改变它本来的宽度和高度,你必须在你获取长度或者宽度之后在乘以你设置的倍数。
* tage_number我们的数组编号是[0,2],初始的时候我们把它的值设置为1,表示第一个平台,
* 当我们每加入一个平台这个数就+1,也就是我们接下来控制的平台,
* 当这个数==2时,+1之后应该是回到第一个平台的编号,所以这里写一个逻辑判断完成这个功能。
*****************************************************/
stage_sprite[stage_number]-&setScaleX(CCRANDOM_0_1() * 40);
stage_sprite[stage_number]-&setPosition(Vec2(visibleSize.width + stage_sprite[stage_number]-&getScaleX() * stage_sprite[stage_number]-&getContentSize().width, stage_sprite[stage_number]-&getContentSize().height / 4));
MoveTo *stageMove = MoveTo::create(0.5f, Vec2(visibleSize.width / 2 + CCRANDOM_0_1() * visibleSize.width / 3, stage_sprite[stage_number]-&getContentSize().height / 4));
stage_sprite[stage_number]-&runAction(stageMove);
if (stage_number + 1 &= 2){
stage_number += 1;
stage_number = 0;
233 bool BackgroundLayer::onTouchBegan(Touch *touch, Event *unused_event){
if (isStart){
//stageMove();
addStick();
return true;
241 void BackgroundLayer::onTouchMoved(Touch *touch, Event *unused_event){
245 void BackgroundLayer::onTouchEnded(Touch *touch, Event *unused_event){
stopStick();
250 void BackgroundLayer::addStick(){
//stageMove();
// 棍子设置在平台的右上角那个点上了
_stick-&setPosition(Vec2(stage_sprite[nowStage]-&getPosition().x + stage_sprite[nowStage]-&getContentSize().width *
stage_sprite[nowStage]-&getScaleX() / 2, stage_sprite[nowStage]-&getContentSize().height / 4 * 3));
//_stick-&setPosition(stickPoint);
//_stick-&setPosition(Vec2(stage_sprite[stage_number]-&getPosition().x + stage_sprite[stage_number]-&getContentSize().width * stage_sprite[stage_number]-&getScaleX() / 2, stage_sprite[stage_number]-&getContentSize().height / 4 * 3));
this-&schedule(schedule_selector(BackgroundLayer::stickLength));
261 void BackgroundLayer::stickLength(float){
_stick-&setScaleY(_stick-&getScaleY() + 1);
266 void BackgroundLayer::stopStick(){
// 存储我们棍子的长度
touchLength = _stick-&getContentSize().height * _stick-&getScaleY();
this-&unschedule(schedule_selector(BackgroundLayer::stickLength));
rotateStickAndGo();
274 void BackgroundLayer::rotateStickAndGo(){
// 算出棍子到中间的平台之间的最小距离(即,计算出到平台前沿的距离)
destLengthMin = abs(
stage_sprite[lastStage]-&getPositionX()
- stage_sprite[nowStage]-&getPositionX()
- stage_sprite[lastStage]-&getContentSize().width
* stage_sprite[lastStage]-&getScaleX() / 2
- stage_sprite[nowStage]-&getContentSize().width
* stage_sprite[nowStage]-&getScaleX() / 2
// 算出棍子到中间的平台之间的最大距离(即,计算出到平台后沿的距离)
destLengthMax = destLengthMin + stage_sprite[nowStage]-&getContentSize().width * stage_sprite[nowStage]-&getScaleX();
// CallFunc是一个动作类回调函数,
// 用这样一个回调可以连接不同精灵同时或者按顺序进行一些动作,这里我们设置棍子和主角两个对象的动画
CallFunc *moveToNext = CallFunc::create(CC_CALLBACK_0(BackgroundLayer::playerMoveToNextStage, this));
RotateTo *stickRotate = RotateTo::create(1.0f, 90);
Sequence *gogo = Sequence::create(stickRotate, moveToNext, NULL);
RotateTo *stickRotateDown = RotateTo::create(1.0f, 180);
CallFunc* GoCallBack = CallFunc::create(CC_CALLBACK_0(BackgroundLayer::PlayerMove, this));
Sequence* StickDown = Sequence::create(stickRotateDown, GoCallBack, NULL);
// 判断语句判断我们计算出的棍子长度是不是在我们最大距离和最小距离之间,
// 若果是就选择90度,反正则旋转180度。
log("%f", touchLength);
log("%f", destLengthMin);
log("%f", destLengthMax);
if (touchLength &= destLengthMin && touchLength &= destLengthMax){
_stick-&runAction(gogo);
if (touchLength & destLengthMin || touchLength & destLengthMax){
_stick-&runAction(StickDown);
311 void BackgroundLayer::stageAndPlayerMove(){
// 简单说明一下计算逻辑,
// 我们每个平台的x坐标都会移动到100这个点上,
// 所以我们只需要加上这个平台一半的宽度,
// 再减去主角的一半的宽度是因为主角需要站到平台上,
// 这样才看着和谐点
dest.x = 100 + stage_sprite[nowStage]-&getContentSize().width * stage_sprite[nowStage]-&getScaleX() / 2 - _player.getSprite()-&getContentSize().width / 2 - 5;
dest.y = stage_sprite[nowStage]-&getContentSize().height / 4 * 3;
MoveTo *playermove = MoveTo::create(1.0f, dest);
_player.getSprite()-&runAction(playermove);
stageMove();
resetStick();
327 void BackgroundLayer::resetStick(){
// 重新设置的角度属性,这样下一次使用的它依然是向上的
_stick-&setRotation(0);
// 将它移动到屏幕之外
_stick-&setPosition(-_stick-&getContentSize().width, -_stick-&getContentSize().height);
// 重新设置了长度属性
_stick-&setScaleY(1);
337 void BackgroundLayer::initStick(){
stickPoint.x = 100 + stage_sprite[nowStage]-&getContentSize().width*stage_sprite[nowStage]-&getScaleX() / 2;
stickPoint.y = stage_sprite[nowStage]-&getContentSize().
343 void BackgroundLayer::playerMoveToNextStage(){
//_player.getSprite()-&runAction(MoveBy::create(1.0f, Vec2(destLengthMin + stage_sprite[nowStage]-&getContentSize().width * stage_sprite[nowStage]-&getScaleX() / 2, 0)));
stageAndPlayerMove();
350 void BackgroundLayer::PlayerDown()
// 这个函数中,我们实现了落下,简单粗暴一点,我直接设置落下800像素的距离。
// 这里我们使用的是MoveBy,提醒一下大家,这个方法和MoveTo是不同的,
// 前者是以自己为起点,以提供的Vec2型变量为一个表示方向和长度向量经行移动,
// 后者是直接移动的指定的点,都有同样的动画效果,根据情况来使用不同的方法。
// 在这里我们顺便加入结束层,
// 层上加一个层是一个很常用的做法,没有问题,
// 但是在场景上加场景,虽然不会报错,但是会有潜在危险,希望大家不要使用。
MoveBy* Down = MoveBy::create(1.0f, Vec2(0, -800));
_player.getSprite()-&runAction(Down);
over = GameOverLayer::create();
this-&addChild(over, 8);
367 void BackgroundLayer::PlayerMove()
MoveBy* GO = MoveBy::create(1.0f, Vec2(touchLength, 0));
CallFunc* DownCallBack = CallFunc::create(CC_CALLBACK_0(BackgroundLayer::PlayerDown, this));
Sequence* Goon = Sequence::create(GO, DownCallBack, NULL);
_player.getSprite()-&runAction(Goon);
1 #ifndef __Player_Layer_H__
2 #define __Player_Layer_H__
4 #include "cocos2d.h"
6 USING_NS_CC;
8 class Player{
10 public:
~Player();
void init();
// 获取精灵
Sprite* getSprite();
// 设置位置
void setPosition(Vec2);
void walk(Vec2);
void stay();
void stop();
// 开始的时候让主角跟着平台走
void start(Vec2);
29 private:
Animation *_walkA
Animation *_stayA
Animate *_walkA
Animate *_stayA
39 #endif __Player_Layer_H__
Player.cpp
1 #include "Player.h"
2 #include "Resource.h"
4 Player::Player(){
8 Player::~Player(){
12 void Player::init(){
_player = Sprite::create(hero1);
_player-&setAnchorPoint(Vec2(0.5, 0));
/**************************************
* 先创建一个Vector类型的数据,用来存储我们动画的每一帧,而这个Vector中的数据类型为SpriteFrame*,
* 在看到循环内,我先定义了一个字符型数组,这个用来存储我们每一帧图片的名字,这样方便后面使用,
* 然后是给这个字符型数组赋值,这里用到的时sprintf()方法,再来说一说SpriteFrame::create()这个方法,
* 这个方法我们一般是用来提取打包图片的(所有帧都是一张图片上),它根据后面Rect的不同来提取不同位置上的图片块,
* 但我们在这里也可以这样使用它,提取不同的图片,Rect的值就是图片的大小。
* 接下来是createWithSpriteFrame()方法,这个方法是用来从一个Vector数据中读取数据来创建一个动画(Animation),
* 其中的第二个参数是这个动画执行的持续时间。接下来一行的方法是用设置动画执行完时是否回到原始状态,
* setLoops()是用来设置这个动画反复执行的次数,
* 最后一句是用Animation对象去创建一个Animate对象,Animate才能被runAciton()方法所接收。
***************************************/
Vector&SpriteFrame*& frameV
for (int i = 1; i &= 5; i++){
char pngName[260] = { 0 };
sprintf(pngName, "image/anim1/stay%d.png", i);
frameVector.pushBack(SpriteFrame::create(pngName, Rect(0, 0, 54, 58)));
_stayAnimation = Animation::createWithSpriteFrames(frameVector, 0.1f);
_stayAnimation-&setRestoreOriginalFrame(false);
_stayAnimation-&setLoops(10000);
_stayAnimat = Animate::create(_stayAnimation);
frameVector.clear();
for (int i = 1; i &= 5; i++){
char pngName[260] = { 0 };
sprintf(pngName, "image/anim1/walk%d.png", i);
frameVector.pushBack(SpriteFrame::create(pngName, Rect(0, 0, 54, 58)));
_walkAnimation = Animation::createWithSpriteFrames(frameVector, 1);
_walkAnimation-&setRestoreOriginalFrame(false);
_walkAnimation-&setLoops(10000);
_walkAnimate = Animate::create(_walkAnimation);
54 Sprite* Player::getSprite(){
59 void Player::setPosition(Vec2 _pos){
_player-&setPosition(_pos);
64 void Player::stay(){
_player-&runAction(_stayAnimat);
69 void Player::stop(){
_player-&stopAllActions();
74 void Player::walk(Vec2 _dec){
MoveTo *move = MoveTo::create(1.5f, _dec);
79 void Player::start(Vec2 _dec){
MoveTo *move = MoveTo::create(1.0f, _dec);
_player-&runAction(move);
GameOverLayer.h
1 #include "cocos2d.h"
2 USING_NS_CC;
4 class GameOverLayer
:public Layer
GameOverLayer();
~GameOverLayer();
CREATE_FUNC(GameOverLayer);
virtual bool init();
void ReStart(Ref*);
GameOverLayer.cpp
1 #include "GameOverLayer.h"
2 #include "WelcomeScene.h"
4 GameOverLayer::GameOverLayer(){
8 GameOverLayer::~GameOverLayer(){
12 bool GameOverLayer::init()
if (!Layer::init())
return false;
Size MyWinSize = Director::getInstance()-&getVisibleSize();
MenuItemSprite* ReStartBtn = MenuItemSprite::create(Sprite::create("image/uires_5.png"), Sprite::create("image/uires_5.png"), NULL, this, menu_selector(GameOverLayer::ReStart));
ReStartBtn-&setPosition(MyWinSize.width / 2, MyWinSize.height / 2 + 8);
Menu* menu = Menu::create(ReStartBtn, NULL);
menu-&setPosition(0, 0);
this-&addChild(menu);
return true;
27 void GameOverLayer::ReStart(cocos2d::Ref * _pSender)
WelcomeScene* scene = WelcomeScene::create();
Director* pDirector = Director::getInstance();
TransitionFade* jump = TransitionFade::create(0.3f, scene);
pDirector-&replaceScene(jump);
阅读(...) 评论()

我要回帖

更多关于 stick hero下载 的文章

 

随机推荐