Cocos2d-3.x_菜单项和菜单的使用

Cocos2d-3.x_菜单项和菜单的使用,第1张

概述#ifndef __HELLOWORLD_SCENE_H__#define __HELLOWORLD_SCENE_H__#include "cocos2d.h"USING_NS_CC;class HelloWorld : public cocos2d::Layer{public: static cocos2d::Scene* createScene(); vi
#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_菜单项和菜单的使用所遇到的程序开发问题。

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

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1054186.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存