Cocos2d-x   发布时间:2022-05-03  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Cocos2d-3.x_菜单项和菜单的使用大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
#ifndef __HelLOWORLD_SCENE_H__
#define __HelLOWORLD_SCENE_H__

#include "cocos2d.h"

USING_NS_Cc;


class HelloWorld : public cocos2d::Layer
{
public:
    static cocos2d::Scene* createScene();

    virtual bool init();

	void menuCloseCallBACk(cocos2d::ref *pSender);

    CREATE_FUNC(HelloWorld);

private:
	LabelTTF *pLabel;
};

#endif // __HelLOWORLD_SCENE_H__
#include "HelloWorldScene.h"

Scene* HelloWorld::createScene()
{
    auto scene = Scene::create();
    auto layer = HelloWorld::create();
    scene->addChild(layer);

    return scene;
}

bool HelloWorld::init()
{
    if ( !Layer::init() )
    {
        return false;
    }
    
    Size visibleSize = Director::geTinstance()->getVisibleSize();
    Vec2 origin = Director::geTinstance()->getVisibLeorigin();

	pLabel = LabelTTF::create("","Arial",30);
	pLabel->setPosition(visibleSize/2.0);
	this->addChild(pLabel);

	auto itemImage = MenuItemImage::create("CloseNormal.png","CloseSELEcted.png",CC_CALLBACK_1(HelloWorld::menuCloseCallBACk,this));
	itemImage->setPosition(Size::ZERO);
	
	auto menu = Menu::create(itemImage,null);
	menu->setPosition(visibleSize / 2.0);
	this->addChild(menu);

    return true;
}

void HelloWorld::menuCloseCallBACk(cocos2d::ref *pSender)
{
	log("HelloWorld::menuCloseCallBACk");
}

大佬总结

以上是大佬教程为你收集整理的Cocos2d-3.x_菜单项和菜单的使用全部内容,希望文章能够帮你解决Cocos2d-3.x_菜单项和菜单的使用所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。