LogoNode:
#ifndef LogoNode_hpp
#define LogoNode_hpp
#include <stdio.h>
#include "cocos2d.h"
USING_NS_CC;
class LogoNode:public Node
{
protected:
Sprite* _logo;
Sprite* _cocosLogo;
public:
LogoNode();
virtual ~LogoNode();
virtual bool init();
CREATE_FUNC(LogoNode);
};
#endif /* LogoNode_hpp */
#include "LogoNode.hpp"
LogoNode::LogoNode():_logo(nullptr),_cocosLogo(nullptr)
{
}
LogoNode::~LogoNode()
{
}
bool LogoNode::init()
{
if (!Node::init()) {
return false;
}
_logo=Sprite::create("Saloon (10).png");
_cocosLogo=Sprite::create("HelloWorld.png");
addChild(_logo);
addChild(_cocosLogo);
_cocosLogo->setVisible(false);
schedule([this](float f){
_logo->setVisible(!_logo->isVisible());
_cocosLogo->setVisible(!_cocosLogo->isVisible());
},1,"test");
return true;
}
GameScene:
#ifndef GameScene_hpp
#define GameScene_hpp
#include <stdio.h>
#include "cocos2d.h"
USING_NS_CC;
class GameScene:public Layer
{
public:
GameScene();
virtual ~GameScene();
virtual bool init();
CREATE_FUNC(GameScene);
static Scene* createScene();
};
#endif /* GameScene_hpp */
#include "GameScene.hpp"
#include "LogoNode.hpp"
GameScene::GameScene()
{
}
GameScene::~GameScene()
{
}
bool GameScene::init()
{
if (!Layer::init()) {
return false;
}
auto logo=LogoNode::create();
addChild(logo);
logo->setPosition(Director::getInstance()->getVisibleSize()/2);
return true;
}
Scene* GameScene::createScene()
{
auto scene=Scene::create();
auto layer=GameScene::create();
scene->addChild(layer);
return scene;
}