Skip to content

Commit

Permalink
info scene with first launch, replaced icons
Browse files Browse the repository at this point in the history
  • Loading branch information
mik403 committed Jul 10, 2014
1 parent 0faeac2 commit f3ff170
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Classes/AppDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ bool AppDelegate::applicationDidFinishLaunching() {
if(!glview) {
glview = GLView::create("Tap and Split");
director->setOpenGLView(glview);//854õ480
//glview->setFrameSize(854, 480);
//glview->setFrameSize(854, 480);static Resource mediumResource = { cocos2d::Size(1024, 768), "ipad" };
// glview->setFrameSize(768, 1024);
}

director->setOpenGLView(glview);
Expand Down
6 changes: 6 additions & 0 deletions Classes/AudioEngineWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class AudioEngineWrapper {

AudioEngineWrapper() {
sound_enabled = true;
prev_song = 0;
songs.push_back("GameScene1.mp3");
songs.push_back("GameScene2.mp3");
songs.push_back("GameScene3.mp3");
Expand All @@ -84,12 +85,17 @@ class AudioEngineWrapper {
char* getRandomTrack() {

int random = rand() % songs.size();
if (prev_song == random) { //the most primitive solution. 2Rewrite
random = rand() % songs.size();
}

char* music = songs.at(random);

return music;
}

bool sound_enabled;
int prev_song;
std::vector <char *> songs;

};
2 changes: 1 addition & 1 deletion Classes/GameScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ bool GameScene::init()
auto touchListener = EventListenerTouchOneByOne::create();

touchListener->onTouchBegan = CC_CALLBACK_2(GameScene::onTouchBegan, this);
this->getEventDispatcher()->addEventListenerWithFixedPriority(touchListener, 5000);
this->getEventDispatcher()->addEventListenerWithSceneGraphPriority(touchListener, this);
return true;
}

Expand Down
21 changes: 21 additions & 0 deletions Classes/InfoScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "AudioEngineWrapper.h"
#include "MenuScene.h"
#include "AppMacros.h"
#include "LevelScene.h"

using namespace ui;

Expand All @@ -14,8 +15,19 @@ bool InfoScene::init() {

setUpUI();


touchListener = EventListenerTouchOneByOne::create();

touchListener->onTouchBegan = CC_CALLBACK_2(InfoScene::onTouchBegan2, this);
this->getEventDispatcher()->addEventListenerWithFixedPriority(touchListener, -1);

return true;
}

InfoScene::~InfoScene() {
this->getEventDispatcher()->removeEventListener(touchListener);
}

// there's no 'id' in cpp, so we recommend returning the class instance pointer
cocos2d::Scene* InfoScene::scene() {
// 'scene' is an autorelease object
Expand Down Expand Up @@ -59,3 +71,12 @@ void InfoScene::setUpUI() {
dynamic_cast<Text *>(m_pLayout->getChildByName("Death_label"))->setFontSize(TITLE_FONT_SIZE);
}

bool InfoScene::onTouchBegan2(Touch* touch, Event* event)
{

AudioEngineWrapper::getInstance()->playPressEffect();

Scene *s = LevelScene::scene();
Director::getInstance()->replaceScene(CCTransitionCrossFade::create(0.5, s));
return true;
}
8 changes: 5 additions & 3 deletions Classes/InfoScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ class InfoScene : public cocos2d::Layer{
public:
// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
virtual bool init();

// there's no 'id' in cpp, so we recommend returning the class instance pointer
static cocos2d::Scene* scene();

// a selector callback
void menuToMainCallback(Ref* sender, ui::Widget::TouchEventType type);

bool onTouchBegan2(Touch *touch, Event *unused_event);
void setUpUI();

EventListenerTouchOneByOne* touchListener;
// implement the "static node()" method manually
CREATE_FUNC(InfoScene);

~InfoScene();
};


Expand Down
15 changes: 13 additions & 2 deletions Classes/MenuScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,20 @@ void MenuScene::menuStartGameCallback(Ref* sender, Widget::TouchEventType type)

AudioEngineWrapper::getInstance()->playPressEffect();

Scene *s = LevelScene::scene();
Director::getInstance()->replaceScene(CCTransitionCrossFade::create(0.5, s));

CCUserDefault *def = CCUserDefault::sharedUserDefault();
bool f_launch = def->getBoolForKey("NOT_FIRST_LAUNCH");

if (!f_launch) {
Scene *s = InfoScene::scene();
Director::getInstance()->replaceScene(CCTransitionCrossFade::create(0.5, s));
def->setBoolForKey("NOT_FIRST_LAUNCH", true);
def->flush();
} else {
Scene *s = LevelScene::scene();
Director::getInstance()->replaceScene(CCTransitionCrossFade::create(0.5, s));
}

}

void MenuScene::menuInfoCallback(Ref* sender, ui::Widget::TouchEventType type) {
Expand Down
Binary file modified Screenshots/ScreenCompleted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed proj.android/bin/TapIt.apk
Binary file not shown.
Binary file modified proj.android/res/drawable-hdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified proj.android/res/drawable-ldpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified proj.android/res/drawable-mdpi/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f3ff170

Please sign in to comment.