2010-08-02 10:58:00 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010 cocos2d-x.org
|
|
|
|
|
|
|
|
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 <stdarg.h>
|
|
|
|
#include "CCLayer.h"
|
2010-08-25 10:19:20 +08:00
|
|
|
#include "CCTouchDispatcher.h"
|
2010-08-02 10:58:00 +08:00
|
|
|
#include "CCDirector.h"
|
2010-08-25 10:19:20 +08:00
|
|
|
#include "CGPointExtension.h"
|
2010-08-04 15:46:12 +08:00
|
|
|
namespace cocos2d {
|
2010-08-02 10:58:00 +08:00
|
|
|
|
2010-07-12 17:56:06 +08:00
|
|
|
// CCLayer
|
|
|
|
CCLayer::CCLayer()
|
2010-08-03 14:50:41 +08:00
|
|
|
:m_bIsTouchEnabled(false)
|
|
|
|
,m_bIsAccelerometerEnabled(false)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2010-09-03 09:32:13 +08:00
|
|
|
m_eTouchDelegateType = ccTouchDeletateAllBit;
|
2010-08-02 10:58:00 +08:00
|
|
|
m_tAnchorPoint = ccp(0.5f, 0.5f);
|
|
|
|
m_bIsRelativeAnchorPoint = false;
|
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
CCLayer::~CCLayer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-08-03 14:50:41 +08:00
|
|
|
bool CCLayer::init()
|
|
|
|
{
|
|
|
|
bool bRet = false;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
CCDirector * pDirector;
|
|
|
|
CCX_BREAK_IF( ! (pDirector = CCDirector::getSharedDirector()) );
|
|
|
|
this->setContentSize(pDirector->getWinSize());
|
|
|
|
// success
|
|
|
|
bRet = true;
|
|
|
|
} while (0);
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
CCLayer *CCLayer::node()
|
|
|
|
{
|
|
|
|
CCLayer *pRet = new CCLayer();
|
2010-08-19 14:09:40 +08:00
|
|
|
if (pRet && pRet->init())
|
2010-08-03 14:50:41 +08:00
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
return pRet;
|
|
|
|
}
|
2010-08-19 14:09:40 +08:00
|
|
|
CCX_SAFE_DELETE(pRet)
|
2010-08-03 14:50:41 +08:00
|
|
|
return NULL;
|
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
/// Touch and Accelerometer related
|
|
|
|
|
|
|
|
void CCLayer::registerWithTouchDispatcher()
|
|
|
|
{
|
2010-07-21 11:13:32 +08:00
|
|
|
CCTouchDispatcher::getSharedDispatcher()->addStandardDelegate(this,0);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-08-27 14:13:32 +08:00
|
|
|
void CCLayer::destroy(void)
|
|
|
|
{
|
|
|
|
this->release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCLayer::keep(void)
|
|
|
|
{
|
|
|
|
this->retain();
|
|
|
|
}
|
|
|
|
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
/// isTouchEnabled getter
|
|
|
|
bool CCLayer::getIsTouchEnabled()
|
|
|
|
{
|
|
|
|
return m_bIsTouchEnabled;
|
|
|
|
}
|
|
|
|
/// isTouchEnabled setter
|
|
|
|
void CCLayer::setIsTouchEnabled(bool enabled)
|
|
|
|
{
|
2010-08-02 10:58:00 +08:00
|
|
|
if (m_bIsTouchEnabled != enabled)
|
|
|
|
{
|
|
|
|
m_bIsTouchEnabled = enabled;
|
|
|
|
if (m_bIsRunning)
|
|
|
|
{
|
|
|
|
if (enabled)
|
|
|
|
{
|
|
|
|
this->registerWithTouchDispatcher();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// have problems?
|
2010-09-03 09:32:13 +08:00
|
|
|
CCTouchDispatcher::getSharedDispatcher()->removeDelegate(this);
|
2010-08-02 10:58:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// isAccelerometerEnabled getter
|
|
|
|
bool CCLayer::getIsAccelerometerEnabled()
|
|
|
|
{
|
|
|
|
return m_bIsAccelerometerEnabled;
|
|
|
|
}
|
|
|
|
/// isAccelerometerEnabled setter
|
|
|
|
void CCLayer::setIsAccelerometerEnabled(bool enabled)
|
|
|
|
{
|
2010-07-21 17:40:10 +08:00
|
|
|
/** @todo UIAccelerometer
|
2010-07-12 17:56:06 +08:00
|
|
|
if( enabled != isAccelerometerEnabled ) {
|
|
|
|
isAccelerometerEnabled = enabled;
|
|
|
|
if( isRunning_ ) {
|
|
|
|
if( enabled )
|
|
|
|
[[UIAccelerometer sharedAccelerometer] setDelegate:self];
|
|
|
|
else
|
|
|
|
[[UIAccelerometer sharedAccelerometer] setDelegate:nil];
|
|
|
|
}
|
|
|
|
}*/
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Callbacks
|
|
|
|
void CCLayer::onEnter()
|
|
|
|
{
|
2010-08-05 18:07:14 +08:00
|
|
|
|
2010-07-12 17:56:06 +08:00
|
|
|
// register 'parent' nodes first
|
|
|
|
// since events are propagated in reverse order
|
2010-08-05 18:07:14 +08:00
|
|
|
if (m_bIsTouchEnabled)
|
|
|
|
{
|
|
|
|
this->registerWithTouchDispatcher();
|
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
// then iterate over all the children
|
2010-09-02 14:54:42 +08:00
|
|
|
CCNode::onEnter();
|
2010-08-05 18:07:14 +08:00
|
|
|
/** @todo UIAccelerometer
|
2010-07-12 17:56:06 +08:00
|
|
|
if( isAccelerometerEnabled )
|
|
|
|
[[UIAccelerometer sharedAccelerometer] setDelegate:self];*/
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCLayer::onExit()
|
|
|
|
{
|
2010-08-05 18:07:14 +08:00
|
|
|
if( m_bIsTouchEnabled )
|
|
|
|
{
|
2010-09-03 09:32:13 +08:00
|
|
|
CCTouchDispatcher::getSharedDispatcher()->removeDelegate(this);
|
2010-08-05 18:07:14 +08:00
|
|
|
}
|
|
|
|
/**
|
2010-07-12 17:56:06 +08:00
|
|
|
if( isAccelerometerEnabled )
|
|
|
|
[[UIAccelerometer sharedAccelerometer] setDelegate:nil];
|
2010-08-05 18:07:14 +08:00
|
|
|
*/
|
2010-09-02 14:54:42 +08:00
|
|
|
CCNode::onExit();
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-07-30 17:18:20 +08:00
|
|
|
bool CCLayer::ccTouchBegan(CCTouch *pTouch, UIEvent *pEvent)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2010-07-30 17:18:20 +08:00
|
|
|
NSAssert(false, "Layer#ccTouchBegan override me");
|
|
|
|
return true;
|
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
/// ColorLayer
|
|
|
|
|
|
|
|
|
|
|
|
CCColorLayer::CCColorLayer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCColorLayer::~CCColorLayer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// Opacity and RGB color protocol
|
|
|
|
/// opacity getter
|
|
|
|
GLubyte CCColorLayer::getOpacity()
|
|
|
|
{
|
|
|
|
return m_cOpacity;
|
|
|
|
}
|
|
|
|
/// opacity setter
|
|
|
|
void CCColorLayer::setOpacity(GLubyte var)
|
|
|
|
{
|
|
|
|
m_cOpacity = var;
|
|
|
|
updateColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// color getter
|
|
|
|
ccColor3B CCColorLayer::getColor()
|
|
|
|
{
|
|
|
|
return m_tColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// color setter
|
|
|
|
void CCColorLayer::setColor(ccColor3B var)
|
|
|
|
{
|
|
|
|
m_tColor = var;
|
|
|
|
updateColor();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// blendFunc getter
|
|
|
|
ccBlendFunc CCColorLayer::getBlendFunc()
|
|
|
|
{
|
|
|
|
return m_tBlendFunc;
|
|
|
|
}
|
|
|
|
/// blendFunc setter
|
|
|
|
void CCColorLayer::setBlendFunc(ccBlendFunc var)
|
|
|
|
{
|
|
|
|
m_tBlendFunc = var;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CCColorLayer * CCColorLayer::layerWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height)
|
|
|
|
{
|
|
|
|
CCColorLayer * pLayer = new CCColorLayer();
|
2010-09-04 12:02:52 +08:00
|
|
|
if( pLayer && pLayer->initWithColorWidthHeight(color,width,height))
|
|
|
|
{
|
|
|
|
pLayer->autorelease();
|
|
|
|
return pLayer;
|
|
|
|
}
|
|
|
|
CCX_SAFE_DELETE(pLayer);
|
|
|
|
return NULL;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
CCColorLayer * CCColorLayer::layerWithColor(ccColor4B color)
|
|
|
|
{
|
|
|
|
CCColorLayer * pLayer = new CCColorLayer();
|
2010-09-04 12:02:52 +08:00
|
|
|
if(pLayer && pLayer->initWithColor(color))
|
|
|
|
{
|
|
|
|
pLayer->autorelease();
|
|
|
|
return pLayer;
|
|
|
|
}
|
|
|
|
CCX_SAFE_DELETE(pLayer);
|
|
|
|
return NULL;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-09-04 12:02:52 +08:00
|
|
|
bool CCColorLayer::initWithColorWidthHeight(ccColor4B color, GLfloat width, GLfloat height)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2010-07-21 11:13:32 +08:00
|
|
|
// default blend function
|
|
|
|
m_tBlendFunc.src = CC_BLEND_SRC;
|
|
|
|
m_tBlendFunc.dst = CC_BLEND_DST;
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-07-21 11:13:32 +08:00
|
|
|
m_tColor.r = color.r;
|
|
|
|
m_tColor.g = color.g;
|
|
|
|
m_tColor.b = color.b;
|
|
|
|
m_cOpacity = color.a;
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-08-02 10:58:00 +08:00
|
|
|
for (unsigned int i=0; i<sizeof(m_pSquareVertices) / sizeof(m_pSquareVertices[0]); i++ )
|
2010-09-04 12:02:52 +08:00
|
|
|
{
|
2010-07-21 11:13:32 +08:00
|
|
|
m_pSquareVertices[i] = 0.0f;
|
2010-09-04 12:02:52 +08:00
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-07-21 11:13:32 +08:00
|
|
|
this->updateColor();
|
|
|
|
this->setContentSize(CGSizeMake(width,height));
|
2010-09-04 12:02:52 +08:00
|
|
|
return true;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-09-04 12:02:52 +08:00
|
|
|
bool CCColorLayer::initWithColor(ccColor4B color)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2010-07-30 16:35:07 +08:00
|
|
|
CGSize s = CCDirector::getSharedDirector()->getWinSize();
|
2010-09-04 12:02:52 +08:00
|
|
|
this->initWithColorWidthHeight(color, s.width, s.height);
|
|
|
|
return true;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// override contentSize
|
|
|
|
void CCColorLayer::setContentSize(CGSize size)
|
|
|
|
{
|
2010-07-21 11:13:32 +08:00
|
|
|
m_pSquareVertices[2] = size.width;
|
|
|
|
m_pSquareVertices[5] = size.height;
|
|
|
|
m_pSquareVertices[6] = size.width;
|
|
|
|
m_pSquareVertices[7] = size.height;
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-09-02 14:54:42 +08:00
|
|
|
CCLayer::setContentSize(size);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCColorLayer::changeWidthAndHeight(GLfloat w ,GLfloat h)
|
|
|
|
{
|
2010-07-21 11:13:32 +08:00
|
|
|
this->setContentSize(CGSizeMake(w, h));
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCColorLayer::changeWidth(GLfloat w)
|
|
|
|
{
|
2010-07-21 11:13:32 +08:00
|
|
|
this->setContentSize(CGSizeMake(w, m_tContentSize.height));
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCColorLayer::changeHeight(GLfloat h)
|
|
|
|
{
|
2010-07-21 11:13:32 +08:00
|
|
|
this->setContentSize(CGSizeMake(m_tContentSize.width, h));
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCColorLayer::updateColor()
|
|
|
|
{
|
2010-08-02 10:58:00 +08:00
|
|
|
for( unsigned int i=0; i < sizeof(m_pSquareColors) / sizeof(m_pSquareColors[0]); i++ )
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
|
|
|
if( i % 4 == 0 )
|
2010-07-21 11:13:32 +08:00
|
|
|
m_pSquareColors[i] = m_tColor.r;
|
2010-07-12 17:56:06 +08:00
|
|
|
else if( i % 4 == 1)
|
2010-07-21 11:13:32 +08:00
|
|
|
m_pSquareColors[i] = m_tColor.g;
|
2010-07-12 17:56:06 +08:00
|
|
|
else if( i % 4 ==2 )
|
2010-07-21 11:13:32 +08:00
|
|
|
m_pSquareColors[i] = m_tColor.b;
|
2010-07-12 17:56:06 +08:00
|
|
|
else
|
2010-07-21 11:13:32 +08:00
|
|
|
m_pSquareColors[i] = m_cOpacity;
|
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCColorLayer::draw()
|
|
|
|
{
|
|
|
|
// Default GL states: GL_TEXTURE_2D, GL_VERTEX_ARRAY, GL_COLOR_ARRAY, GL_TEXTURE_COORD_ARRAY
|
|
|
|
// Needed states: GL_VERTEX_ARRAY, GL_COLOR_ARRAY
|
|
|
|
// Unneeded states: GL_TEXTURE_2D, GL_TEXTURE_COORD_ARRAY
|
|
|
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
|
|
glDisable(GL_TEXTURE_2D);
|
|
|
|
|
2010-07-21 11:13:32 +08:00
|
|
|
glVertexPointer(2, GL_FLOAT, 0, m_pSquareVertices);
|
|
|
|
glColorPointer(4, GL_UNSIGNED_BYTE, 0, m_pSquareColors);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-07-21 11:13:32 +08:00
|
|
|
bool newBlend = false;
|
|
|
|
if( m_tBlendFunc.src != CC_BLEND_SRC || m_tBlendFunc.dst != CC_BLEND_DST ) {
|
|
|
|
newBlend = true;
|
|
|
|
glBlendFunc(m_tBlendFunc.src, m_tBlendFunc.dst);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
2010-07-21 11:13:32 +08:00
|
|
|
else if( m_cOpacity != 255 ) {
|
|
|
|
newBlend = true;
|
2010-07-12 17:56:06 +08:00
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
}
|
|
|
|
|
|
|
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
|
|
|
|
|
|
|
if( newBlend )
|
|
|
|
glBlendFunc(CC_BLEND_SRC, CC_BLEND_DST);
|
|
|
|
|
|
|
|
// restore default GL state
|
|
|
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
2010-07-21 11:13:32 +08:00
|
|
|
glEnable(GL_TEXTURE_2D);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// MultiplexLayer
|
|
|
|
|
|
|
|
CCMultiplexLayer::CCMultiplexLayer()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
CCMultiplexLayer::~CCMultiplexLayer()
|
|
|
|
{
|
2010-08-02 10:58:00 +08:00
|
|
|
m_pLayers->release();
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCMultiplexLayer * CCMultiplexLayer::layerWithLayers(CCLayer * layer, ...)
|
|
|
|
{
|
2010-07-21 11:13:32 +08:00
|
|
|
va_list args;
|
2010-07-12 17:56:06 +08:00
|
|
|
va_start(args,layer);
|
|
|
|
|
2010-07-21 11:13:32 +08:00
|
|
|
CCMultiplexLayer * pMultiplexLayer = new CCMultiplexLayer();
|
2010-09-04 12:02:52 +08:00
|
|
|
if(pMultiplexLayer && pMultiplexLayer->initWithLayers(layer, args))
|
|
|
|
{
|
|
|
|
pMultiplexLayer->autorelease();
|
|
|
|
va_end(args);
|
|
|
|
return pMultiplexLayer;
|
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
va_end(args);
|
2010-09-04 12:02:52 +08:00
|
|
|
CCX_SAFE_DELETE(pMultiplexLayer);
|
|
|
|
return NULL;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-09-04 12:02:52 +08:00
|
|
|
bool CCMultiplexLayer::initWithLayers(CCLayer *layer, va_list params)
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2010-07-21 11:13:32 +08:00
|
|
|
m_pLayers = new NSMutableArray<CCLayer*>(5);
|
|
|
|
m_pLayers->retain();
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-07-21 11:13:32 +08:00
|
|
|
m_pLayers->addObject(layer);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-07-21 11:13:32 +08:00
|
|
|
CCLayer *l = va_arg(params,CCLayer*);
|
|
|
|
while( l ) {
|
|
|
|
m_pLayers->addObject(l);
|
|
|
|
l = va_arg(params,CCLayer*);
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-07-21 11:13:32 +08:00
|
|
|
m_nEnabledLayer = 0;
|
|
|
|
this->addChild(m_pLayers->getObjectAtIndex(m_nEnabledLayer));
|
|
|
|
|
2010-09-04 12:02:52 +08:00
|
|
|
return true;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCMultiplexLayer::switchTo(unsigned int n)
|
|
|
|
{
|
2010-07-21 11:13:32 +08:00
|
|
|
NSAssert( n < m_pLayers->count(), "Invalid index in MultiplexLayer switchTo message" );
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-07-21 11:13:32 +08:00
|
|
|
this->removeChild(m_pLayers->getObjectAtIndex(m_nEnabledLayer), true);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-07-21 11:13:32 +08:00
|
|
|
m_nEnabledLayer = n;
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-07-21 11:13:32 +08:00
|
|
|
this->addChild(m_pLayers->getObjectAtIndex(n));
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCMultiplexLayer::switchToAndReleaseMe(unsigned int n)
|
|
|
|
{
|
2010-07-21 11:13:32 +08:00
|
|
|
NSAssert( n < m_pLayers->count(), "Invalid index in MultiplexLayer switchTo message" );
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-07-21 11:13:32 +08:00
|
|
|
this->removeChild(m_pLayers->getObjectAtIndex(m_nEnabledLayer), true);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-07-21 11:13:32 +08:00
|
|
|
//[layers replaceObjectAtIndex:enabledLayer withObject:[NSNull null]];
|
|
|
|
m_pLayers->replaceObjectAtIndex(m_nEnabledLayer, NULL);
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-07-21 11:13:32 +08:00
|
|
|
m_nEnabledLayer = n;
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-07-21 11:13:32 +08:00
|
|
|
this->addChild(m_pLayers->getObjectAtIndex(n));
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
2010-08-04 15:46:12 +08:00
|
|
|
}//namespace cocos2d
|