zoukankan      html  css  js  c++  java
  • Cocos2d-x -- 图片菜单按钮

    Scene* MainMenu::createScene()
    {
        // 'scene' is an autorelease object
        auto scene = Scene::create();
        
        // 'layer' is an autorelease object
        auto layer = MainMenu::create();
    
        // add layer as a child to scene
        scene->addChild(layer);
    
        // return the scene
        return scene;
    }
    
    // on "init" you need to initialize your instance
    bool MainMenu::init()
    {
        //////////////////////////////
        // 1. super init first
        if ( !Layer::init() )
        {
            return false;
        }
        
        Size visibleSize = Director::getInstance()->getVisibleSize();
        Point origin = Director::getInstance()->getVisibleOrigin();
        
        auto menuTitle = MenuItemImage::create("MainMenuScreen/Game_Title.png",
                                               "MainMenuScreen/Game_Title.png");
        auto playItem = MenuItemImage::create("MainMenuScreen/Play_Button.png",
                                              "MainMenuScreen/Play_Button(Click).png",
                                              CC_CALLBACK_1(MainMenu::GoToGameScene, this));
        
        auto menu = Menu::create(menuTitle, playItem, NULL);
        menu->alignItemsVerticallyWithPadding(visibleSize.height / 4);
        this->addChild(menu);
        
        return true;
    }
    
    void MainMenu::GoToGameScene(cocos2d::Ref *pSender)
    {
        auto scene = GameScreen::createScene();
        
        Director::getInstance()->replaceScene(scene);
    }
  • 相关阅读:
    Python M3 面向对象
    Python 基础
    Python 基础
    Python 基础
    Python 作业
    Python 基础
    Python 基础
    【机器学习】周志华 读书笔记 第三章 线性模型
    【机器学习】周志华 读书笔记 第二章 模型评估与选择
    【机器学习】周志华 读书笔记 第一章 绪论
  • 原文地址:https://www.cnblogs.com/davidgu/p/4762633.html
Copyright © 2011-2022 走看看