-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
aboutLayer,position confirm.
- Loading branch information
Showing
5 changed files
with
95 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#include "About.h" | ||
#include "HelloWorldScene.h" | ||
USING_NS_CC; | ||
|
||
Scene* GameAbout::createScene() | ||
{ | ||
auto scene = Scene::create(); | ||
auto layer = GameAbout::create(); | ||
scene->addChild(layer); | ||
return scene; | ||
} | ||
|
||
|
||
bool GameAbout::init() | ||
{ | ||
|
||
if ( !Layer::init() ) | ||
{ | ||
return false; | ||
} | ||
|
||
Size visibleSize = Director::getInstance()->getVisibleSize(); | ||
Point origin = Director::getInstance()->getVisibleOrigin(); | ||
//背景 | ||
auto sprite = Sprite::create("about/aboutui.png"); | ||
sprite->setPosition(Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y)); | ||
this->addChild(sprite); | ||
|
||
//响应键盘消息 | ||
auto keyListener = EventListenerKeyboard::create(); | ||
keyListener->onKeyReleased = CC_CALLBACK_2(GameAbout::onKeyReleased, this); | ||
_eventDispatcher->addEventListenerWithSceneGraphPriority(keyListener, this); | ||
|
||
//可以触控 | ||
this->setTouchEnabled(true); | ||
auto touchListener = EventListenerTouchOneByOne::create(); | ||
touchListener->onTouchBegan = CC_CALLBACK_2(GameAbout::onTouchBegan, this); | ||
_eventDispatcher->addEventListenerWithSceneGraphPriority(touchListener, this); | ||
return true; | ||
} | ||
|
||
//返回主界面 | ||
void GameAbout::onKeyReleased(EventKeyboard::KeyCode keycode,Event* event) | ||
{ | ||
if(keycode == EventKeyboard::KeyCode::KEY_BACKSPACE) | ||
{ | ||
Scene* newScene = HelloWorld::createScene(); | ||
HelloWorld* layer = HelloWorld::create(); | ||
newScene->addChild(layer); | ||
Director::sharedDirector()->pushScene(newScene); | ||
} | ||
} | ||
|
||
//响应触摸 | ||
bool GameAbout::onTouchBegan(Touch *touch, Event *unused) | ||
{ | ||
CCLOG("here"); | ||
Director::sharedDirector()->replaceScene(HelloWorld::createScene()); | ||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#ifndef __GameAbout_H__ | ||
#define __GameAbout_H__ | ||
|
||
#include "cocos2d.h" | ||
|
||
USING_NS_CC; | ||
|
||
|
||
class GameAbout : public Layer | ||
{ | ||
public: | ||
static cocos2d::Scene* createScene(); | ||
virtual bool init(); | ||
//响应安卓返回键 | ||
virtual void onKeyReleased(EventKeyboard::KeyCode keycode,Event* event)override; | ||
//点击函数 | ||
virtual bool onTouchBegan(Touch *touch, Event *unused) override; | ||
CREATE_FUNC(GameAbout); | ||
}; | ||
|
||
#endif // __GameAbout_H__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
using namespace std; | ||
|
||
void func1() | ||
void func2() | ||
{ | ||
return ; | ||
|
||
|