mirror of https://github.com/axmolengine/axmol.git
issue #157 retain & release
This commit is contained in:
parent
9535831c85
commit
ea4ea4b5a2
|
@ -16,6 +16,7 @@ bool GameOverScene::init()
|
||||||
if( CCScene::init() )
|
if( CCScene::init() )
|
||||||
{
|
{
|
||||||
this->_layer = GameOverLayer::node();
|
this->_layer = GameOverLayer::node();
|
||||||
|
_layer->retain(); // notice! in objc it's a property with "retain"
|
||||||
this->addChild(_layer);
|
this->addChild(_layer);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -28,8 +29,11 @@ bool GameOverScene::init()
|
||||||
|
|
||||||
GameOverScene::~GameOverScene()
|
GameOverScene::~GameOverScene()
|
||||||
{
|
{
|
||||||
// _layer->release();
|
if (_layer)
|
||||||
// _layer = NULL;
|
{
|
||||||
|
_layer->release();
|
||||||
|
_layer = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
@ -39,6 +43,7 @@ bool GameOverLayer::init()
|
||||||
{
|
{
|
||||||
CGSize winSize = CCDirector::getSharedDirector()->getWinSize();
|
CGSize winSize = CCDirector::getSharedDirector()->getWinSize();
|
||||||
this->_label = CCLabel::labelWithString("", "Artial", 32);
|
this->_label = CCLabel::labelWithString("", "Artial", 32);
|
||||||
|
_label->retain(); // notice! in objc it's a property with "retain"
|
||||||
_label->setColor( ccc3(0, 0, 0) );
|
_label->setColor( ccc3(0, 0, 0) );
|
||||||
_label->setPosition( ccp(winSize.width/2, winSize.height/2) );
|
_label->setPosition( ccp(winSize.width/2, winSize.height/2) );
|
||||||
this->addChild(_label);
|
this->addChild(_label);
|
||||||
|
@ -63,6 +68,9 @@ void GameOverLayer::gameOverDone()
|
||||||
|
|
||||||
GameOverLayer::~GameOverLayer()
|
GameOverLayer::~GameOverLayer()
|
||||||
{
|
{
|
||||||
// _label->release();
|
if (_label)
|
||||||
// _label = NULL;
|
{
|
||||||
}
|
_label->release();
|
||||||
|
_label = NULL;
|
||||||
|
}
|
||||||
|
}
|
|
@ -14,31 +14,25 @@
|
||||||
class GameOverLayer : public cocos2d::CCColorLayer
|
class GameOverLayer : public cocos2d::CCColorLayer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
GameOverLayer():_label(NULL) {};
|
||||||
virtual ~GameOverLayer();
|
virtual ~GameOverLayer();
|
||||||
|
bool init();
|
||||||
LAYER_NODE_FUNC(GameOverLayer);
|
LAYER_NODE_FUNC(GameOverLayer);
|
||||||
|
|
||||||
bool init();
|
|
||||||
void gameOverDone();
|
void gameOverDone();
|
||||||
|
|
||||||
inline cocos2d::CCLabel* getLabel() { return _label; };
|
CCX_SYNTHESIZE_READONLY(cocos2d::CCLabel*, _label, Label);
|
||||||
protected:
|
|
||||||
cocos2d::CCLabel *_label;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class GameOverScene : public cocos2d::CCScene
|
class GameOverScene : public cocos2d::CCScene
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~GameOverScene();
|
GameOverScene():_layer(NULL) {};
|
||||||
|
~GameOverScene();
|
||||||
bool init();
|
bool init();
|
||||||
|
|
||||||
SCENE_NODE_FUNC(GameOverScene);
|
SCENE_NODE_FUNC(GameOverScene);
|
||||||
|
|
||||||
public:
|
CCX_SYNTHESIZE_READONLY(GameOverLayer*, _layer, Layer);
|
||||||
inline GameOverLayer* getLayer() {return _layer; };
|
|
||||||
protected:
|
|
||||||
GameOverLayer *_layer;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _GAME_OVER_SCENE_H_
|
#endif // _GAME_OVER_SCENE_H_
|
||||||
|
|
Loading…
Reference in New Issue