2012-09-09 20:20:29 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010-2011 cocos2d-x.org
|
|
|
|
Copyright (c) 2010 Ray Wenderlich
|
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include "GameOverScene.h"
|
|
|
|
#include "HelloWorldScene.h"
|
|
|
|
|
|
|
|
using namespace cocos2d;
|
|
|
|
|
2013-07-02 08:10:37 +08:00
|
|
|
namespace simplegame {
|
|
|
|
|
2012-09-09 20:20:29 +08:00
|
|
|
bool GameOverScene::init()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
if( Scene::init() )
|
2012-09-09 20:20:29 +08:00
|
|
|
{
|
|
|
|
this->_layer = GameOverLayer::create();
|
|
|
|
this->_layer->retain();
|
|
|
|
this->addChild(_layer);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GameOverScene::~GameOverScene()
|
|
|
|
{
|
|
|
|
if (_layer)
|
|
|
|
{
|
|
|
|
_layer->release();
|
|
|
|
_layer = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool GameOverLayer::init()
|
|
|
|
{
|
2013-07-05 16:49:22 +08:00
|
|
|
if ( LayerColor::initWithColor( Color4B(255,255,255,255) ) )
|
2012-09-09 20:20:29 +08:00
|
|
|
{
|
2013-07-12 06:24:23 +08:00
|
|
|
Size winSize = Director::getInstance()->getWinSize();
|
2013-06-20 14:17:10 +08:00
|
|
|
this->_label = LabelTTF::create("","Artial", 32);
|
2012-09-09 20:20:29 +08:00
|
|
|
_label->retain();
|
2013-07-05 16:49:22 +08:00
|
|
|
_label->setColor( Color3B(0, 0, 0) );
|
2013-07-12 18:04:32 +08:00
|
|
|
_label->setPosition( Point(winSize.width/2, winSize.height/2) );
|
2012-09-09 20:20:29 +08:00
|
|
|
this->addChild(_label);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
this->runAction( Sequence::create(
|
|
|
|
DelayTime::create(3),
|
2013-07-16 03:43:22 +08:00
|
|
|
CallFunc::create( CC_CALLBACK_0(GameOverLayer::gameOverDone, this)),
|
2012-09-09 20:20:29 +08:00
|
|
|
NULL));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameOverLayer::gameOverDone()
|
|
|
|
{
|
2013-07-12 06:24:23 +08:00
|
|
|
Director::getInstance()->replaceScene( HelloWorld::scene() );
|
2012-09-09 20:20:29 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GameOverLayer::~GameOverLayer()
|
|
|
|
{
|
|
|
|
if (_label)
|
|
|
|
{
|
|
|
|
_label->release();
|
|
|
|
_label = NULL;
|
|
|
|
}
|
|
|
|
}
|
2013-07-02 08:10:37 +08:00
|
|
|
|
|
|
|
}
|