zoukankan      html  css  js  c++  java
  • Cocos2d 之FlyBird开发---GameAbout类

    |   版权声明:本文为博主原创文章,未经博主允许不得转载。(笔者才疏学浅,如有错误,请多多指教)

      一般像游戏关于的这种界面中,主要显示的是游戏的玩法等。

    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/

    效果图:

  • 相关阅读:
    unomi漏洞复现
    xxl-job漏洞复现
    cgi漏洞复现
    celery漏洞复现
    bash漏洞复现
    学习ASP.NET的一些学习资源
    用EF DataBase First做一个简单的MVC3报名页面
    怎样在Word中插入代码并保持代码原始样式不变
    安装notepad++之后怎样在鼠标右键上加上Edit with notepad++
    安装Visual Studio 2010之后怎样安装MSDN Library
  • 原文地址:https://www.cnblogs.com/geore/p/5800098.html
Copyright © 2011-2022 走看看