| Index: nacltoons/src/FrontEnd.cc
|
| diff --git a/nacltoons/src/FrontEnd.cc b/nacltoons/src/FrontEnd.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..d0b73383c71219ad3f0807f86025d9364d895902
|
| --- /dev/null
|
| +++ b/nacltoons/src/FrontEnd.cc
|
| @@ -0,0 +1,51 @@
|
| +// Copyright (c) 2013 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +#include "FrontEnd.h"
|
| +#include "GameplayScene.h"
|
| +
|
| +USING_NS_CC;
|
| +
|
| +CCScene* FrontEnd::scene() {
|
| + CCScene* scene = CCScene::create();
|
| + CCLayer* frontend = FrontEnd::create();
|
| + scene->addChild(frontend);
|
| + return scene;
|
| +}
|
| +
|
| +void FrontEnd::StartGame(CCObject* sender) {
|
| + CCLog("StartGame pressed");
|
| + CCTransitionScene* transition;
|
| + CCDirector* director = CCDirector::sharedDirector();
|
| +
|
| + // transition to a new Gameplay scene.
|
| + CCScene* scene = Gameplay::scene();
|
| + director->setDepthTest(true);
|
| + transition = CCTransitionPageTurn::create(1.0f, scene, false);
|
| + director->pushScene(transition);
|
| +}
|
| +
|
| +bool FrontEnd::init() {
|
| + if (!CCLayerColor::initWithColor(ccc4(0, 0xD8, 0x8F, 0xD8)))
|
| + return false;
|
| +
|
| + setTouchEnabled(true);
|
| +
|
| + // Create and position the menu.
|
| + CCLabelTTF* start_label = CCLabelTTF::create("Start Game", "Arial.ttf", 24);
|
| +
|
| + CCMenuItemLabel* start = CCMenuItemLabel::create(start_label,
|
| + this, menu_selector(FrontEnd::StartGame));
|
| +
|
| + CCMenu* menu = CCMenu::create(start, NULL);
|
| + addChild(menu);
|
| +
|
| + // Position Menu
|
| + CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();
|
| + CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();
|
| + menu->alignItemsVertically();
|
| + float xpos = origin.x + visibleSize.width/2;
|
| + float ypos = origin.y + visibleSize.height/2;
|
| + menu->setPosition(ccp(xpos, ypos));
|
| + return true;
|
| +}
|
|
|