-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUIWelcome.cpp
64 lines (54 loc) · 1.62 KB
/
UIWelcome.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//
// GameMainScene.cpp
// HelloCpp
//
// Created by shaoleibo on 15-1-31.
// Copyright (c) 2015年 Bullets in a Burning Box, Inc. All rights reserved.
//
#include "UIWelcome.h"
#include "GameMainScene.h"
#include "UIManager.h"
#include "GameMap.h"
USING_NS_CC;
USING_NS_CC_EXT;
using namespace gui;
bool UIWelcome::init()
{
m_fileName = "WelcomeUI.ExportJson";
if( UIBase::init())
{
// parse
m_pLoadGame = static_cast<UIButton*>(m_pWidget->getChildByName("loadGameBtn"));
m_pStartGame = static_cast<UIButton*>(m_pWidget->getChildByName("starGameBtn"));
// register Event
m_pLoadGame->addTouchEventListener( this,toucheventselector(UIWelcome::loadGameCallBack));
m_pStartGame->addTouchEventListener( this,toucheventselector(UIWelcome::starGameCallBack));
return true;
}
return false;
}
void UIWelcome::starGameCallBack( ::cocos2d::CCObject* pSender, ::cocos2d::ui::TouchEventType type )
{
if(type == cocos2d::ui::TOUCH_EVENT_ENDED)
{
UIManager::GetInstance()->state = NewGame;
CCDirector::sharedDirector()->purgeCachedData();
CCScene* pScene = GameMainScene::scene();
CCDirector::sharedDirector()->replaceScene(pScene);
}
}
void UIWelcome::loadGameCallBack( ::cocos2d::CCObject* pSender, ::cocos2d::ui::TouchEventType type )
{
if(type == cocos2d::ui::TOUCH_EVENT_ENDED)
{
UIManager::GetInstance()->state = LoadGame;
CCDirector::sharedDirector()->purgeCachedData();
CCScene* pScene = GameMainScene::scene();
CCDirector::sharedDirector()->replaceScene(pScene);
}
}
UIWelcome::~UIWelcome()
{
m_pStartGame = NULL;
m_pLoadGame = NULL;
}