Skip to content

Instantly share code, notes, and snippets.

@shinriyo
Created October 11, 2012 02:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shinriyo/3869899 to your computer and use it in GitHub Desktop.
Save shinriyo/3869899 to your computer and use it in GitHub Desktop.
Tiledゲームのパート3のGameOverSceneのソース
//
// GameOverScene.cpp
// TileBasedGame
//
// Created by sugita on 12/10/11.
// Copyright (c) 2012 __shinriyo__. All rights reserved.
//
#include "GameOverScene.h"
#include "HelloWorldScene.h"
USING_NS_CC;
// using namespace cocos2d;
bool GameOverScene::init()
{
if( CCScene::init() )
{
this->_layer = GameOverLayer::node();
this->_layer->retain();
this->addChild(_layer);
return true;
}
else
{
return false;
}
}
GameOverScene::~GameOverScene()
{
if (_layer)
{
_layer->release();
_layer = NULL;
}
}
// on "init" you need to initialize your instance
bool GameOverLayer::init()
{
if (CCLayerColor::initWithColor (ccc4 ( 255 , 255 , 255 , 255 )))
{
CCSize winSize = CCDirector::sharedDirector()->getWinSize();
this->_label = CCLabelTTF::labelWithString("","Artial", 32);
_label->setColor(cocos2d::ccc3(0,0,0));
_label->setPosition(ccp(winSize.width/2, winSize.height/2));
this->addChild(_label);
this->runAction( CCSequence::actions(
CCDelayTime::actionWithDuration(3),
CCCallFunc::actionWithTarget(this,
callfunc_selector(GameOverLayer::gameOverDone)),
NULL));
return true;
}
else {
return false;
}
}
void GameOverLayer::gameOverDone()
{
CCDirector::sharedDirector()->replaceScene(HelloWorld::scene());
}
GameOverLayer::~GameOverLayer()
{
if (_label)
{
_label->release();
_label = NULL;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment