2010-12-18 16:12:59 +08:00
|
|
|
/****************************************************************************
|
2012-06-14 15:13:16 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2011-03-19 14:45:51 +08:00
|
|
|
Copyright (c) 2008-2010 Ricardo Quesada
|
|
|
|
Copyright (c) 2009 Valentin Milea
|
2011-07-01 15:48:05 +08:00
|
|
|
Copyright (c) 2011 Zynga Inc.
|
2010-12-18 16:12:59 +08:00
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
2012-06-19 16:20:46 +08:00
|
|
|
#include "cocoa/CCString.h"
|
2010-12-18 16:12:59 +08:00
|
|
|
#include "CCNode.h"
|
2012-06-19 16:20:46 +08:00
|
|
|
#include "support/CCPointExtension.h"
|
2010-12-18 16:12:59 +08:00
|
|
|
#include "support/TransformUtils.h"
|
|
|
|
#include "CCCamera.h"
|
|
|
|
#include "effects/CCGrid.h"
|
|
|
|
#include "CCDirector.h"
|
|
|
|
#include "CCScheduler.h"
|
2012-06-19 16:20:46 +08:00
|
|
|
#include "touch_dispatcher/CCTouch.h"
|
|
|
|
#include "actions/CCActionManager.h"
|
|
|
|
#include "script_support/CCScriptSupport.h"
|
|
|
|
#include "shaders/CCGLProgram.h"
|
2012-04-04 21:58:04 +08:00
|
|
|
// externals
|
2012-03-14 14:55:17 +08:00
|
|
|
#include "kazmath/GL/matrix.h"
|
2013-06-04 17:38:43 +08:00
|
|
|
#include "support/component/CCComponent.h"
|
|
|
|
#include "support/component/CCComponentContainer.h"
|
2012-04-14 19:11:57 +08:00
|
|
|
|
2012-03-23 10:26:36 +08:00
|
|
|
#if CC_NODE_RENDER_SUBPIXEL
|
2010-07-20 14:29:18 +08:00
|
|
|
#define RENDER_IN_SUBPIXEL
|
|
|
|
#else
|
2013-04-13 15:18:54 +08:00
|
|
|
#define RENDER_IN_SUBPIXEL(__ARGS__) (ceil(__ARGS__))
|
2010-07-20 14:29:18 +08:00
|
|
|
#endif
|
2010-12-18 16:12:59 +08:00
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
NS_CC_BEGIN
|
2010-12-18 16:12:59 +08:00
|
|
|
|
2012-04-04 21:58:04 +08:00
|
|
|
// XXX: Yes, nodes might have a sort problem once every 15 days if the game runs at 60 FPS and each frame sprites are reordered.
|
2012-03-14 14:55:17 +08:00
|
|
|
static int s_globalOrderOfArrival = 1;
|
|
|
|
|
2010-12-18 16:12:59 +08:00
|
|
|
CCNode::CCNode(void)
|
2013-06-15 14:03:30 +08:00
|
|
|
: _rotationX(0.0f)
|
|
|
|
, _rotationY(0.0f)
|
|
|
|
, _scaleX(1.0f)
|
|
|
|
, _scaleY(1.0f)
|
|
|
|
, _vertexZ(0.0f)
|
|
|
|
, _position(CCPointZero)
|
|
|
|
, _skewX(0.0f)
|
|
|
|
, _skewY(0.0f)
|
|
|
|
, _anchorPointInPoints(CCPointZero)
|
|
|
|
, _anchorPoint(CCPointZero)
|
|
|
|
, _contentSize(CCSizeZero)
|
|
|
|
, _additionalTransform(CCAffineTransformMakeIdentity())
|
|
|
|
, _camera(NULL)
|
2011-06-10 17:51:37 +08:00
|
|
|
// children (lazy allocs)
|
|
|
|
// lazy alloc
|
2013-06-15 14:03:30 +08:00
|
|
|
, _grid(NULL)
|
|
|
|
, _ZOrder(0)
|
|
|
|
, _children(NULL)
|
|
|
|
, _parent(NULL)
|
|
|
|
// "whole screen" objects. like Scenes and Layers, should set _ignoreAnchorPointForPosition to true
|
|
|
|
, _tag(kCCNodeTagInvalid)
|
2011-06-10 17:51:37 +08:00
|
|
|
// userData is always inited as nil
|
2013-06-15 14:03:30 +08:00
|
|
|
, _userData(NULL)
|
|
|
|
, _userObject(NULL)
|
|
|
|
, _shaderProgram(NULL)
|
|
|
|
, _GLServerState(ccGLServerState(0))
|
|
|
|
, _orderOfArrival(0)
|
|
|
|
, _running(false)
|
|
|
|
, _transformDirty(true)
|
|
|
|
, _inverseDirty(true)
|
|
|
|
, _additionalTransformDirty(false)
|
|
|
|
, _visible(true)
|
|
|
|
, _ignoreAnchorPointForPosition(false)
|
|
|
|
, _reorderChildDirty(false)
|
|
|
|
, _isTransitionFinished(false)
|
|
|
|
, _scriptHandler(0)
|
|
|
|
, _updateScriptHandler(0)
|
|
|
|
, _componentContainer(NULL)
|
2010-12-18 16:12:59 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
// set default scheduler and actionManager
|
|
|
|
CCDirector *director = CCDirector::sharedDirector();
|
2013-06-15 14:03:30 +08:00
|
|
|
_actionManager = director->getActionManager();
|
|
|
|
_actionManager->retain();
|
|
|
|
_scheduler = director->getScheduler();
|
|
|
|
_scheduler->retain();
|
2012-08-31 21:23:23 +08:00
|
|
|
|
|
|
|
CCScriptEngineProtocol* pEngine = CCScriptEngineManager::sharedManager()->getScriptEngine();
|
2013-06-15 14:03:30 +08:00
|
|
|
_scriptType = pEngine != NULL ? pEngine->getScriptType() : kScriptTypeNone;
|
|
|
|
_componentContainer = new CCComponentContainer(this);
|
2010-12-18 16:12:59 +08:00
|
|
|
}
|
2012-03-14 18:11:25 +08:00
|
|
|
|
2012-01-09 23:21:31 +08:00
|
|
|
CCNode::~CCNode(void)
|
2010-12-18 16:12:59 +08:00
|
|
|
{
|
2013-06-06 09:21:05 +08:00
|
|
|
CCLOGINFO( "cocos2d: deallocing: %p", this );
|
2012-09-21 00:21:24 +08:00
|
|
|
|
|
|
|
unregisterScriptHandler();
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_updateScriptHandler)
|
2012-12-10 13:48:27 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
CCScriptEngineManager::sharedManager()->getScriptEngine()->removeScriptHandler(_updateScriptHandler);
|
2012-12-10 13:48:27 +08:00
|
|
|
}
|
2010-07-14 10:36:26 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_actionManager);
|
|
|
|
CC_SAFE_RELEASE(_scheduler);
|
2012-04-19 14:35:52 +08:00
|
|
|
// attributes
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_camera);
|
2010-07-14 10:36:26 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_grid);
|
|
|
|
CC_SAFE_RELEASE(_shaderProgram);
|
|
|
|
CC_SAFE_RELEASE(_userObject);
|
2010-07-14 10:36:26 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if(_children && _children->count() > 0)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2011-04-21 14:46:15 +08:00
|
|
|
CCObject* child;
|
2013-06-15 14:03:30 +08:00
|
|
|
CCARRAY_FOREACH(_children, child)
|
2011-04-21 14:46:15 +08:00
|
|
|
{
|
|
|
|
CCNode* pChild = (CCNode*) child;
|
|
|
|
if (pChild)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
pChild->_parent = NULL;
|
2011-04-21 14:46:15 +08:00
|
|
|
}
|
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2010-07-14 10:36:26 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// children
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_children);
|
2013-06-04 17:38:43 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
// _comsContainer
|
|
|
|
_componentContainer->removeAll();
|
|
|
|
CC_SAFE_DELETE(_componentContainer);
|
2010-12-18 16:12:59 +08:00
|
|
|
}
|
|
|
|
|
2013-02-27 09:38:30 +08:00
|
|
|
bool CCNode::init()
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-07-01 15:48:05 +08:00
|
|
|
float CCNode::getSkewX()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _skewX;
|
2011-07-01 15:48:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::setSkewX(float newSkewX)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_skewX = newSkewX;
|
|
|
|
_transformDirty = _inverseDirty = true;
|
2011-07-01 15:48:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
float CCNode::getSkewY()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _skewY;
|
2011-07-01 15:48:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::setSkewY(float newSkewY)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_skewY = newSkewY;
|
2011-07-01 15:48:05 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_transformDirty = _inverseDirty = true;
|
2011-07-01 15:48:05 +08:00
|
|
|
}
|
|
|
|
|
2010-12-18 16:12:59 +08:00
|
|
|
/// zOrder getter
|
2011-07-06 20:48:56 +08:00
|
|
|
int CCNode::getZOrder()
|
2010-12-18 16:12:59 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _ZOrder;
|
2010-12-18 16:12:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// zOrder setter : private method
|
2010-07-14 10:36:26 +08:00
|
|
|
/// used internally to alter the zOrder variable. DON'T call this method manually
|
2012-03-16 13:42:53 +08:00
|
|
|
void CCNode::_setZOrder(int z)
|
2010-07-14 10:36:26 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_ZOrder = z;
|
2010-12-18 16:12:59 +08:00
|
|
|
}
|
|
|
|
|
2012-03-16 13:42:53 +08:00
|
|
|
void CCNode::setZOrder(int z)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
_setZOrder(z);
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_parent)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_parent->reorderChild(this, z);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2012-03-16 13:42:53 +08:00
|
|
|
}
|
|
|
|
|
2012-09-17 15:02:24 +08:00
|
|
|
/// vertexZ getter
|
2010-12-18 16:12:59 +08:00
|
|
|
float CCNode::getVertexZ()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _vertexZ;
|
2010-12-18 16:12:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// vertexZ setter
|
|
|
|
void CCNode::setVertexZ(float var)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_vertexZ = var;
|
2010-12-18 16:12:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// rotation getter
|
|
|
|
float CCNode::getRotation()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
CCAssert(_rotationX == _rotationY, "CCNode#rotation. RotationX != RotationY. Don't know which one to return");
|
|
|
|
return _rotationX;
|
2010-12-18 16:12:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// rotation setter
|
2010-07-12 17:56:06 +08:00
|
|
|
void CCNode::setRotation(float newRotation)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_rotationX = _rotationY = newRotation;
|
|
|
|
_transformDirty = _inverseDirty = true;
|
2012-11-14 18:05:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
float CCNode::getRotationX()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _rotationX;
|
2012-11-14 18:05:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::setRotationX(float fRotationX)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_rotationX = fRotationX;
|
|
|
|
_transformDirty = _inverseDirty = true;
|
2012-11-14 18:05:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
float CCNode::getRotationY()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _rotationY;
|
2012-11-14 18:05:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::setRotationY(float fRotationY)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_rotationY = fRotationY;
|
|
|
|
_transformDirty = _inverseDirty = true;
|
2010-12-18 16:12:59 +08:00
|
|
|
}
|
|
|
|
|
2010-07-12 17:56:06 +08:00
|
|
|
/// scale getter
|
|
|
|
float CCNode::getScale(void)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
CCAssert( _scaleX == _scaleY, "CCNode#scale. ScaleX != ScaleY. Don't know which one to return");
|
|
|
|
return _scaleX;
|
2010-12-18 16:12:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// scale setter
|
2010-07-12 17:56:06 +08:00
|
|
|
void CCNode::setScale(float scale)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_scaleX = _scaleY = scale;
|
|
|
|
_transformDirty = _inverseDirty = true;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
2010-12-18 16:12:59 +08:00
|
|
|
|
|
|
|
/// scaleX getter
|
2010-07-08 10:26:58 +08:00
|
|
|
float CCNode::getScaleX()
|
2010-07-07 15:24:44 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _scaleX;
|
2010-12-18 16:12:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// scaleX setter
|
2010-07-12 17:56:06 +08:00
|
|
|
void CCNode::setScaleX(float newScaleX)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_scaleX = newScaleX;
|
|
|
|
_transformDirty = _inverseDirty = true;
|
2010-07-07 15:24:44 +08:00
|
|
|
}
|
2010-12-18 16:12:59 +08:00
|
|
|
|
|
|
|
/// scaleY getter
|
2010-07-08 10:26:58 +08:00
|
|
|
float CCNode::getScaleY()
|
2010-07-07 15:24:44 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _scaleY;
|
2010-12-18 16:12:59 +08:00
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
/// scaleY setter
|
|
|
|
void CCNode::setScaleY(float newScaleY)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_scaleY = newScaleY;
|
|
|
|
_transformDirty = _inverseDirty = true;
|
2010-12-18 16:12:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// position getter
|
2013-01-14 15:51:53 +08:00
|
|
|
const CCPoint& CCNode::getPosition()
|
2010-12-18 16:12:59 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _position;
|
2010-12-18 16:12:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// position setter
|
2011-08-17 21:19:57 +08:00
|
|
|
void CCNode::setPosition(const CCPoint& newPosition)
|
2010-07-07 15:24:44 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_position = newPosition;
|
|
|
|
_transformDirty = _inverseDirty = true;
|
2010-12-31 14:56:24 +08:00
|
|
|
}
|
|
|
|
|
2012-02-02 10:39:19 +08:00
|
|
|
void CCNode::getPosition(float* x, float* y)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
*x = _position.x;
|
|
|
|
*y = _position.y;
|
2012-02-02 10:39:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::setPosition(float x, float y)
|
|
|
|
{
|
|
|
|
setPosition(ccp(x, y));
|
|
|
|
}
|
|
|
|
|
2013-01-21 16:26:02 +08:00
|
|
|
float CCNode::getPositionX(void)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _position.x;
|
2013-01-21 16:26:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
float CCNode::getPositionY(void)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _position.y;
|
2013-01-21 16:26:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::setPositionX(float x)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
setPosition(ccp(x, _position.y));
|
2013-01-21 16:26:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::setPositionY(float y)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
setPosition(ccp(_position.x, y));
|
2013-01-21 16:26:02 +08:00
|
|
|
}
|
|
|
|
|
2010-07-12 17:56:06 +08:00
|
|
|
/// children getter
|
2011-04-21 14:46:15 +08:00
|
|
|
CCArray* CCNode::getChildren()
|
2010-07-07 15:24:44 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _children;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2013-05-13 02:45:41 +08:00
|
|
|
unsigned int CCNode::getChildrenCount(void) const
|
2012-02-02 10:39:19 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _children ? _children->count() : 0;
|
2012-02-02 10:39:19 +08:00
|
|
|
}
|
|
|
|
|
2010-07-14 10:36:26 +08:00
|
|
|
/// camera getter: lazy alloc
|
|
|
|
CCCamera* CCNode::getCamera()
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (!_camera)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_camera = new CCCamera();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
return _camera;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2010-07-14 10:36:26 +08:00
|
|
|
|
2010-12-18 16:12:59 +08:00
|
|
|
/// grid getter
|
2010-07-14 10:36:26 +08:00
|
|
|
CCGridBase* CCNode::getGrid()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _grid;
|
2010-07-07 15:24:44 +08:00
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
|
2010-07-14 10:36:26 +08:00
|
|
|
/// grid setter
|
|
|
|
void CCNode::setGrid(CCGridBase* pGrid)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CC_SAFE_RETAIN(pGrid);
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_grid);
|
|
|
|
_grid = pGrid;
|
2010-07-14 10:36:26 +08:00
|
|
|
}
|
2010-07-07 15:24:44 +08:00
|
|
|
|
|
|
|
|
2010-07-12 17:56:06 +08:00
|
|
|
/// isVisible getter
|
2012-06-15 15:10:40 +08:00
|
|
|
bool CCNode::isVisible()
|
2010-07-07 15:24:44 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _visible;
|
2010-07-07 15:24:44 +08:00
|
|
|
}
|
|
|
|
|
2010-07-12 17:56:06 +08:00
|
|
|
/// isVisible setter
|
2012-06-15 15:10:40 +08:00
|
|
|
void CCNode::setVisible(bool var)
|
2010-07-07 15:24:44 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_visible = var;
|
2010-07-07 15:24:44 +08:00
|
|
|
}
|
|
|
|
|
2013-01-14 15:51:53 +08:00
|
|
|
const CCPoint& CCNode::getAnchorPointInPoints()
|
2012-03-14 14:55:17 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _anchorPointInPoints;
|
2012-03-14 14:55:17 +08:00
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
|
|
|
|
/// anchorPoint getter
|
2013-01-14 15:51:53 +08:00
|
|
|
const CCPoint& CCNode::getAnchorPoint()
|
2010-07-07 15:24:44 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _anchorPoint;
|
2010-12-18 16:12:59 +08:00
|
|
|
}
|
|
|
|
|
2011-08-17 21:19:57 +08:00
|
|
|
void CCNode::setAnchorPoint(const CCPoint& point)
|
2010-07-08 10:26:58 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if( ! point.equals(_anchorPoint))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_anchorPoint = point;
|
|
|
|
_anchorPointInPoints = ccp(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
|
|
|
|
_transformDirty = _inverseDirty = true;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// contentSize getter
|
2013-05-09 06:20:08 +08:00
|
|
|
const CCSize& CCNode::getContentSize() const
|
2010-07-12 17:56:06 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _contentSize;
|
2010-07-12 17:56:06 +08:00
|
|
|
}
|
|
|
|
|
2012-07-27 16:57:56 +08:00
|
|
|
void CCNode::setContentSize(const CCSize & size)
|
2010-07-07 15:24:44 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if ( ! size.equals(_contentSize))
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_contentSize = size;
|
2011-01-04 17:46:23 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_anchorPointInPoints = ccp(_contentSize.width * _anchorPoint.x, _contentSize.height * _anchorPoint.y );
|
|
|
|
_transformDirty = _inverseDirty = true;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2010-07-07 15:24:44 +08:00
|
|
|
}
|
|
|
|
|
2011-01-31 06:59:03 +08:00
|
|
|
// isRunning getter
|
2012-06-15 15:10:40 +08:00
|
|
|
bool CCNode::isRunning()
|
2010-07-07 15:24:44 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _running;
|
2010-07-07 15:24:44 +08:00
|
|
|
}
|
|
|
|
|
2010-07-12 17:56:06 +08:00
|
|
|
/// parent getter
|
|
|
|
CCNode * CCNode::getParent()
|
2010-07-07 15:24:44 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _parent;
|
2010-07-07 15:24:44 +08:00
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
/// parent setter
|
|
|
|
void CCNode::setParent(CCNode * var)
|
2010-07-07 15:24:44 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_parent = var;
|
2010-07-07 15:24:44 +08:00
|
|
|
}
|
|
|
|
|
2010-07-12 17:56:06 +08:00
|
|
|
/// isRelativeAnchorPoint getter
|
2012-06-15 15:10:40 +08:00
|
|
|
bool CCNode::isIgnoreAnchorPointForPosition()
|
2010-07-07 15:24:44 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _ignoreAnchorPointForPosition;
|
2010-07-07 15:24:44 +08:00
|
|
|
}
|
2010-07-12 17:56:06 +08:00
|
|
|
/// isRelativeAnchorPoint setter
|
2012-06-15 15:10:40 +08:00
|
|
|
void CCNode::ignoreAnchorPointForPosition(bool newValue)
|
2010-07-07 15:24:44 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (newValue != _ignoreAnchorPointForPosition)
|
2012-06-08 14:17:39 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_ignoreAnchorPointForPosition = newValue;
|
|
|
|
_transformDirty = _inverseDirty = true;
|
2012-06-08 14:17:39 +08:00
|
|
|
}
|
2010-12-18 16:12:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// tag getter
|
2013-05-09 06:20:08 +08:00
|
|
|
int CCNode::getTag() const
|
2010-12-18 16:12:59 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _tag;
|
2010-12-18 16:12:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// tag setter
|
|
|
|
void CCNode::setTag(int var)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_tag = var;
|
2010-12-18 16:12:59 +08:00
|
|
|
}
|
|
|
|
|
2010-07-12 17:56:06 +08:00
|
|
|
/// userData getter
|
|
|
|
void * CCNode::getUserData()
|
2010-07-07 15:24:44 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _userData;
|
2010-07-07 15:24:44 +08:00
|
|
|
}
|
|
|
|
|
2010-07-12 17:56:06 +08:00
|
|
|
/// userData setter
|
|
|
|
void CCNode::setUserData(void *var)
|
2010-07-07 15:24:44 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_userData = var;
|
2010-07-07 15:24:44 +08:00
|
|
|
}
|
2010-12-18 16:12:59 +08:00
|
|
|
|
2012-11-14 18:05:15 +08:00
|
|
|
unsigned int CCNode::getOrderOfArrival()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _orderOfArrival;
|
2012-11-14 18:05:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::setOrderOfArrival(unsigned int uOrderOfArrival)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_orderOfArrival = uOrderOfArrival;
|
2012-11-14 18:05:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCGLProgram* CCNode::getShaderProgram()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _shaderProgram;
|
2012-11-14 18:05:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCObject* CCNode::getUserObject()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _userObject;
|
2012-11-14 18:05:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ccGLServerState CCNode::getGLServerState()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _GLServerState;
|
2012-11-14 18:05:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::setGLServerState(ccGLServerState glServerState)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_GLServerState = glServerState;
|
2012-11-14 18:05:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::setUserObject(CCObject *pUserObject)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_userObject);
|
2012-11-26 22:11:04 +08:00
|
|
|
CC_SAFE_RETAIN(pUserObject);
|
2013-06-15 14:03:30 +08:00
|
|
|
_userObject = pUserObject;
|
2012-11-14 18:05:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::setShaderProgram(CCGLProgram *pShaderProgram)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_shaderProgram);
|
|
|
|
_shaderProgram = pShaderProgram;
|
|
|
|
CC_SAFE_RETAIN(_shaderProgram);
|
2012-11-14 18:05:15 +08:00
|
|
|
}
|
2010-12-18 16:12:59 +08:00
|
|
|
|
2011-03-07 17:11:57 +08:00
|
|
|
CCRect CCNode::boundingBox()
|
2010-07-20 14:29:18 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
CCRect rect = CCRectMake(0, 0, _contentSize.width, _contentSize.height);
|
2012-04-19 14:35:52 +08:00
|
|
|
return CCRectApplyAffineTransform(rect, nodeToParentTransform());
|
2010-07-20 14:29:18 +08:00
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2012-06-14 15:13:16 +08:00
|
|
|
CCNode * CCNode::create(void)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-06-14 15:13:16 +08:00
|
|
|
CCNode * pRet = new CCNode();
|
2013-02-27 09:38:30 +08:00
|
|
|
if (pRet && pRet->init())
|
|
|
|
{
|
|
|
|
pRet->autorelease();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CC_SAFE_DELETE(pRet);
|
|
|
|
}
|
2012-06-14 15:13:16 +08:00
|
|
|
return pRet;
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::cleanup()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
// actions
|
|
|
|
this->stopAllActions();
|
2012-10-23 01:48:22 +08:00
|
|
|
this->unscheduleAllSelectors();
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if ( _scriptType != kScriptTypeNone)
|
2012-10-23 01:48:22 +08:00
|
|
|
{
|
|
|
|
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeNodeEvent(this, kCCNodeOnCleanup);
|
|
|
|
}
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// timers
|
2013-06-15 14:03:30 +08:00
|
|
|
arrayMakeObjectsPerformSelector(_children, cleanup, CCNode*);
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
2010-07-14 10:36:26 +08:00
|
|
|
|
2010-07-15 11:39:05 +08:00
|
|
|
|
2012-04-14 19:11:57 +08:00
|
|
|
const char* CCNode::description()
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return CCString::createWithFormat("<CCNode | Tag = %d>", _tag)->getCString();
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// lazy allocs
|
|
|
|
void CCNode::childrenAlloc(void)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_children = CCArray::createWithCapacity(4);
|
|
|
|
_children->retain();
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
2011-07-06 20:48:56 +08:00
|
|
|
CCNode* CCNode::getChildByTag(int aTag)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCAssert( aTag != kCCNodeTagInvalid, "Invalid tag");
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if(_children && _children->count() > 0)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2011-04-21 14:46:15 +08:00
|
|
|
CCObject* child;
|
2013-06-15 14:03:30 +08:00
|
|
|
CCARRAY_FOREACH(_children, child)
|
2011-04-21 14:46:15 +08:00
|
|
|
{
|
|
|
|
CCNode* pNode = (CCNode*) child;
|
2013-06-15 14:03:30 +08:00
|
|
|
if(pNode && pNode->_tag == aTag)
|
2012-04-19 14:35:52 +08:00
|
|
|
return pNode;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/* "add" logic MUST only be on this method
|
2012-09-17 15:02:24 +08:00
|
|
|
* If a class want's to extend the 'addChild' behavior it only needs
|
2010-07-09 18:24:08 +08:00
|
|
|
* to override this method
|
|
|
|
*/
|
2011-07-06 20:48:56 +08:00
|
|
|
void CCNode::addChild(CCNode *child, int zOrder, int tag)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
CCAssert( child != NULL, "Argument must be non-nil");
|
2013-06-15 14:03:30 +08:00
|
|
|
CCAssert( child->_parent == NULL, "child already added. It can't be added again");
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if( ! _children )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
this->childrenAlloc();
|
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
this->insertChild(child, zOrder);
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
child->_tag = tag;
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
child->setParent(this);
|
|
|
|
child->setOrderOfArrival(s_globalOrderOfArrival++);
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if( _running )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
child->onEnter();
|
2013-05-27 20:46:15 +08:00
|
|
|
// prevent onEnterTransitionDidFinish to be called twice when a node is added in onEnter
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_isTransitionFinished) {
|
2013-05-27 20:46:15 +08:00
|
|
|
child->onEnterTransitionDidFinish();
|
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
2011-07-06 20:48:56 +08:00
|
|
|
void CCNode::addChild(CCNode *child, int zOrder)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCAssert( child != NULL, "Argument must be non-nil");
|
2013-06-15 14:03:30 +08:00
|
|
|
this->addChild(child, zOrder, child->_tag);
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
2010-12-24 15:21:57 +08:00
|
|
|
void CCNode::addChild(CCNode *child)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCAssert( child != NULL, "Argument must be non-nil");
|
2013-06-15 14:03:30 +08:00
|
|
|
this->addChild(child, child->_ZOrder, child->_tag);
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
2012-11-09 12:08:18 +08:00
|
|
|
void CCNode::removeFromParent()
|
|
|
|
{
|
|
|
|
this->removeFromParentAndCleanup(true);
|
2012-11-05 18:41:52 +08:00
|
|
|
}
|
|
|
|
|
2010-07-09 18:24:08 +08:00
|
|
|
void CCNode::removeFromParentAndCleanup(bool cleanup)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_parent != NULL)
|
2012-05-02 12:04:27 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_parent->removeChild(this,cleanup);
|
2012-05-02 12:04:27 +08:00
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
2012-11-05 18:41:52 +08:00
|
|
|
void CCNode::removeChild(CCNode* child)
|
|
|
|
{
|
|
|
|
this->removeChild(child, true);
|
|
|
|
}
|
|
|
|
|
2010-07-09 18:24:08 +08:00
|
|
|
/* "remove" logic MUST only be on this method
|
|
|
|
* If a class want's to extend the 'removeChild' behavior it only needs
|
|
|
|
* to override this method
|
|
|
|
*/
|
2010-07-14 10:36:26 +08:00
|
|
|
void CCNode::removeChild(CCNode* child, bool cleanup)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
// explicit nil handling
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_children == NULL)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if ( _children->containsObject(child) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
this->detachChild(child,cleanup);
|
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
2012-11-05 18:41:52 +08:00
|
|
|
void CCNode::removeChildByTag(int tag)
|
|
|
|
{
|
|
|
|
this->removeChildByTag(tag, true);
|
|
|
|
}
|
|
|
|
|
2011-07-06 20:48:56 +08:00
|
|
|
void CCNode::removeChildByTag(int tag, bool cleanup)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCAssert( tag != kCCNodeTagInvalid, "Invalid tag");
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
CCNode *child = this->getChildByTag(tag);
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
if (child == NULL)
|
|
|
|
{
|
2013-04-28 03:15:00 +08:00
|
|
|
CCLOG("cocos2d: removeChildByTag(tag = %d): child not found!", tag);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->removeChild(child, cleanup);
|
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
2012-11-05 18:41:52 +08:00
|
|
|
void CCNode::removeAllChildren()
|
|
|
|
{
|
|
|
|
this->removeAllChildrenWithCleanup(true);
|
|
|
|
}
|
|
|
|
|
2010-07-09 18:24:08 +08:00
|
|
|
void CCNode::removeAllChildrenWithCleanup(bool cleanup)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
// not using detachChild improves speed here
|
2013-06-15 14:03:30 +08:00
|
|
|
if ( _children && _children->count() > 0 )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2011-04-21 14:46:15 +08:00
|
|
|
CCObject* child;
|
2013-06-15 14:03:30 +08:00
|
|
|
CCARRAY_FOREACH(_children, child)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2011-04-21 14:46:15 +08:00
|
|
|
CCNode* pNode = (CCNode*) child;
|
2012-04-19 14:35:52 +08:00
|
|
|
if (pNode)
|
|
|
|
{
|
|
|
|
// IMPORTANT:
|
|
|
|
// -1st do onExit
|
|
|
|
// -2nd cleanup
|
2013-06-15 14:03:30 +08:00
|
|
|
if(_running)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
pNode->onExitTransitionDidStart();
|
|
|
|
pNode->onExit();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cleanup)
|
|
|
|
{
|
|
|
|
pNode->cleanup();
|
|
|
|
}
|
|
|
|
// set parent nil at the end
|
|
|
|
pNode->setParent(NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_children->removeAllObjects();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
|
|
|
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::detachChild(CCNode *child, bool doCleanup)
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
// IMPORTANT:
|
|
|
|
// -1st do onExit
|
|
|
|
// -2nd cleanup
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_running)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
child->onExitTransitionDidStart();
|
|
|
|
child->onExit();
|
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// If you don't do cleanup, the child's actions will not get removed and the
|
|
|
|
// its scheduledSelectors_ dict will not get released!
|
|
|
|
if (doCleanup)
|
|
|
|
{
|
|
|
|
child->cleanup();
|
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// set parent nil at the end
|
|
|
|
child->setParent(NULL);
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_children->removeObject(child);
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// helper used by reorderChild & add
|
2011-07-06 20:48:56 +08:00
|
|
|
void CCNode::insertChild(CCNode* child, int z)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_reorderChildDirty = true;
|
|
|
|
ccArrayAppendObjectWithResize(_children->data, child);
|
2012-03-16 17:56:19 +08:00
|
|
|
child->_setZOrder(z);
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
2011-07-06 20:48:56 +08:00
|
|
|
void CCNode::reorderChild(CCNode *child, int zOrder)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCAssert( child != NULL, "Child must be non-nil");
|
2013-06-15 14:03:30 +08:00
|
|
|
_reorderChildDirty = true;
|
2012-04-19 14:35:52 +08:00
|
|
|
child->setOrderOfArrival(s_globalOrderOfArrival++);
|
|
|
|
child->_setZOrder(zOrder);
|
2012-03-14 14:55:17 +08:00
|
|
|
}
|
|
|
|
|
2012-04-04 21:58:04 +08:00
|
|
|
void CCNode::sortAllChildren()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_reorderChildDirty)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
int i,j,length = _children->data->num;
|
|
|
|
CCNode ** x = (CCNode**)_children->data->arr;
|
2012-04-19 14:35:52 +08:00
|
|
|
CCNode *tempItem;
|
2012-04-04 21:58:04 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// insertion sort
|
|
|
|
for(i=1; i<length; i++)
|
|
|
|
{
|
|
|
|
tempItem = x[i];
|
|
|
|
j = i-1;
|
2012-04-04 21:58:04 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
//continue moving element downwards while zOrder is smaller or when zOrder is the same but mutatedIndex is smaller
|
2013-06-15 14:03:30 +08:00
|
|
|
while(j>=0 && ( tempItem->_ZOrder < x[j]->_ZOrder || ( tempItem->_ZOrder== x[j]->_ZOrder && tempItem->_orderOfArrival < x[j]->_orderOfArrival ) ) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
x[j+1] = x[j];
|
|
|
|
j = j-1;
|
|
|
|
}
|
|
|
|
x[j+1] = tempItem;
|
|
|
|
}
|
2012-04-04 21:58:04 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
//don't need to check children recursively, that's done in visit of each child
|
2012-04-04 21:58:04 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_reorderChildDirty = false;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2012-04-04 21:58:04 +08:00
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
|
|
|
|
|
2010-12-18 16:12:59 +08:00
|
|
|
void CCNode::draw()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
//CCAssert(0);
|
|
|
|
// override me
|
2012-09-15 06:26:38 +08:00
|
|
|
// Only use- this function to draw your stuff.
|
2012-04-19 14:35:52 +08:00
|
|
|
// DON'T draw your stuff outside this method
|
2010-12-18 16:12:59 +08:00
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
|
|
|
|
void CCNode::visit()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
// quick return if not visible. children won't be drawn.
|
2013-06-15 14:03:30 +08:00
|
|
|
if (!_visible)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
kmGLPushMatrix();
|
2010-08-17 14:25:41 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_grid && _grid->isActive())
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_grid->beforeDraw();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2010-12-18 16:12:59 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
this->transform();
|
2010-08-04 10:36:37 +08:00
|
|
|
|
2011-04-21 14:46:15 +08:00
|
|
|
CCNode* pNode = NULL;
|
|
|
|
unsigned int i = 0;
|
2010-08-04 10:36:37 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if(_children && _children->count() > 0)
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
sortAllChildren();
|
|
|
|
// draw children zOrder < 0
|
2013-06-15 14:03:30 +08:00
|
|
|
ccArray *arrayData = _children->data;
|
2011-04-21 14:46:15 +08:00
|
|
|
for( ; i < arrayData->num; i++ )
|
|
|
|
{
|
|
|
|
pNode = (CCNode*) arrayData->arr[i];
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if ( pNode && pNode->_ZOrder < 0 )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
pNode->visit();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// self draw
|
|
|
|
this->draw();
|
|
|
|
|
|
|
|
for( ; i < arrayData->num; i++ )
|
|
|
|
{
|
|
|
|
pNode = (CCNode*) arrayData->arr[i];
|
|
|
|
if (pNode)
|
|
|
|
{
|
|
|
|
pNode->visit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this->draw();
|
|
|
|
}
|
|
|
|
|
|
|
|
// reset for next frame
|
2013-06-15 14:03:30 +08:00
|
|
|
_orderOfArrival = 0;
|
2012-04-19 14:35:52 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_grid && _grid->isActive())
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_grid->afterDraw(this);
|
2012-03-14 14:55:17 +08:00
|
|
|
}
|
2010-08-17 14:25:41 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
kmGLPopMatrix();
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::transformAncestors()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if( _parent != NULL )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_parent->transformAncestors();
|
|
|
|
_parent->transform();
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::transform()
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
|
|
|
kmMat4 transfrom4x4;
|
2012-04-04 21:58:04 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// Convert 3x3 into 4x4 matrix
|
|
|
|
CCAffineTransform tmpAffine = this->nodeToParentTransform();
|
|
|
|
CGAffineToGL(&tmpAffine, transfrom4x4.mat);
|
2012-04-04 21:58:04 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// Update Z vertex manually
|
2013-06-15 14:03:30 +08:00
|
|
|
transfrom4x4.mat[14] = _vertexZ;
|
2012-04-04 21:58:04 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
kmGLMultMatrix( &transfrom4x4 );
|
2012-04-04 21:58:04 +08:00
|
|
|
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// XXX: Expensive calls. Camera should be integrated into the cached affine matrix
|
2013-06-15 14:03:30 +08:00
|
|
|
if ( _camera != NULL && !(_grid != NULL && _grid->isActive()) )
|
2012-04-19 14:35:52 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
bool translate = (_anchorPointInPoints.x != 0.0f || _anchorPointInPoints.y != 0.0f);
|
2012-04-04 21:58:04 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
if( translate )
|
2013-06-15 14:03:30 +08:00
|
|
|
kmGLTranslatef(RENDER_IN_SUBPIXEL(_anchorPointInPoints.x), RENDER_IN_SUBPIXEL(_anchorPointInPoints.y), 0 );
|
2012-04-04 21:58:04 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_camera->locate();
|
2012-04-04 21:58:04 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
if( translate )
|
2013-06-15 14:03:30 +08:00
|
|
|
kmGLTranslatef(RENDER_IN_SUBPIXEL(-_anchorPointInPoints.x), RENDER_IN_SUBPIXEL(-_anchorPointInPoints.y), 0 );
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CCNode::onEnter()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_isTransitionFinished = false;
|
2013-05-27 20:46:15 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
arrayMakeObjectsPerformSelector(_children, onEnter, CCNode*);
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
this->resumeSchedulerAndActions();
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_running = true;
|
2012-02-02 15:58:10 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_scriptType != kScriptTypeNone)
|
2012-08-31 17:55:45 +08:00
|
|
|
{
|
2012-09-11 14:02:33 +08:00
|
|
|
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeNodeEvent(this, kCCNodeOnEnter);
|
2012-02-02 15:58:10 +08:00
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::onEnterTransitionDidFinish()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_isTransitionFinished = true;
|
2013-05-27 20:46:15 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
arrayMakeObjectsPerformSelector(_children, onEnterTransitionDidFinish, CCNode*);
|
2012-08-31 21:23:23 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_scriptType == kScriptTypeJavascript)
|
2012-08-31 17:55:45 +08:00
|
|
|
{
|
2012-09-11 14:02:33 +08:00
|
|
|
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeNodeEvent(this, kCCNodeOnEnterTransitionDidFinish);
|
2012-08-31 17:55:45 +08:00
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
2012-04-04 21:58:04 +08:00
|
|
|
void CCNode::onExitTransitionDidStart()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
arrayMakeObjectsPerformSelector(_children, onExitTransitionDidStart, CCNode*);
|
2012-08-31 21:23:23 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_scriptType == kScriptTypeJavascript)
|
2012-08-31 17:55:45 +08:00
|
|
|
{
|
2012-09-11 14:02:33 +08:00
|
|
|
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeNodeEvent(this, kCCNodeOnExitTransitionDidStart);
|
2012-08-31 17:55:45 +08:00
|
|
|
}
|
2012-03-14 14:55:17 +08:00
|
|
|
}
|
|
|
|
|
2010-07-09 18:24:08 +08:00
|
|
|
void CCNode::onExit()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
this->pauseSchedulerAndActions();
|
2010-07-14 10:36:26 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_running = false;
|
2010-07-14 10:36:26 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if ( _scriptType != kScriptTypeNone)
|
2012-08-31 17:55:45 +08:00
|
|
|
{
|
2012-09-11 14:02:33 +08:00
|
|
|
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeNodeEvent(this, kCCNodeOnExit);
|
2012-08-31 17:55:45 +08:00
|
|
|
}
|
2012-02-02 15:58:10 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
arrayMakeObjectsPerformSelector(_children, onExit, CCNode*);
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
2012-02-02 15:58:10 +08:00
|
|
|
|
2012-02-07 11:43:29 +08:00
|
|
|
void CCNode::registerScriptHandler(int nHandler)
|
2012-02-02 15:58:10 +08:00
|
|
|
{
|
|
|
|
unregisterScriptHandler();
|
2013-06-15 14:03:30 +08:00
|
|
|
_scriptHandler = nHandler;
|
|
|
|
LUALOG("[LUA] Add CCNode event handler: %d", _scriptHandler);
|
2012-02-02 15:58:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::unregisterScriptHandler(void)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_scriptHandler)
|
2012-02-02 15:58:10 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
CCScriptEngineManager::sharedManager()->getScriptEngine()->removeScriptHandler(_scriptHandler);
|
|
|
|
LUALOG("[LUA] Remove CCNode event handler: %d", _scriptHandler);
|
|
|
|
_scriptHandler = 0;
|
2012-02-02 15:58:10 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-04 21:58:04 +08:00
|
|
|
void CCNode::setActionManager(CCActionManager* actionManager)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if( actionManager != _actionManager ) {
|
2012-04-19 14:35:52 +08:00
|
|
|
this->stopAllActions();
|
|
|
|
CC_SAFE_RETAIN(actionManager);
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_actionManager);
|
|
|
|
_actionManager = actionManager;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2012-04-04 21:58:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCActionManager* CCNode::getActionManager()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _actionManager;
|
2012-03-14 14:55:17 +08:00
|
|
|
}
|
|
|
|
|
2010-08-06 09:46:56 +08:00
|
|
|
CCAction * CCNode::runAction(CCAction* action)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCAssert( action != NULL, "Argument must be non-nil");
|
2013-06-15 14:03:30 +08:00
|
|
|
_actionManager->addAction(action, this, !_running);
|
2012-04-19 14:35:52 +08:00
|
|
|
return action;
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::stopAllActions()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_actionManager->removeAllActionsFromTarget(this);
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
2010-08-06 09:46:56 +08:00
|
|
|
void CCNode::stopAction(CCAction* action)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_actionManager->removeAction(action);
|
2010-08-06 09:46:56 +08:00
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2011-07-06 20:48:56 +08:00
|
|
|
void CCNode::stopActionByTag(int tag)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCAssert( tag != kCCActionTagInvalid, "Invalid tag");
|
2013-06-15 14:03:30 +08:00
|
|
|
_actionManager->removeActionByTag(tag, this);
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
2011-07-06 20:48:56 +08:00
|
|
|
CCAction * CCNode::getActionByTag(int tag)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCAssert( tag != kCCActionTagInvalid, "Invalid tag");
|
2013-06-15 14:03:30 +08:00
|
|
|
return _actionManager->getActionByTag(tag, this);
|
2010-08-06 09:46:56 +08:00
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2011-07-01 15:48:05 +08:00
|
|
|
unsigned int CCNode::numberOfRunningActions()
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _actionManager->numberOfRunningActionsInTarget(this);
|
2012-03-14 14:55:17 +08:00
|
|
|
}
|
|
|
|
|
2010-07-14 16:30:25 +08:00
|
|
|
// CCNode - Callbacks
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2012-04-04 21:58:04 +08:00
|
|
|
void CCNode::setScheduler(CCScheduler* scheduler)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if( scheduler != _scheduler ) {
|
2012-04-19 14:35:52 +08:00
|
|
|
this->unscheduleAllSelectors();
|
|
|
|
CC_SAFE_RETAIN(scheduler);
|
2013-06-15 14:03:30 +08:00
|
|
|
CC_SAFE_RELEASE(_scheduler);
|
|
|
|
_scheduler = scheduler;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2012-04-04 21:58:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
CCScheduler* CCNode::getScheduler()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _scheduler;
|
2012-04-04 21:58:04 +08:00
|
|
|
}
|
2012-03-14 14:55:17 +08:00
|
|
|
|
2010-07-09 18:24:08 +08:00
|
|
|
void CCNode::scheduleUpdate()
|
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
scheduleUpdateWithPriority(0);
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
2011-07-06 20:48:56 +08:00
|
|
|
void CCNode::scheduleUpdateWithPriority(int priority)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_scheduler->scheduleUpdateForTarget(this, priority, !_running);
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
2013-01-17 11:20:25 +08:00
|
|
|
void CCNode::scheduleUpdateWithPriorityLua(int nHandler, int priority)
|
|
|
|
{
|
|
|
|
unscheduleUpdate();
|
2013-06-15 14:03:30 +08:00
|
|
|
_updateScriptHandler = nHandler;
|
|
|
|
_scheduler->scheduleUpdateForTarget(this, priority, !_running);
|
2013-01-17 11:20:25 +08:00
|
|
|
}
|
|
|
|
|
2010-07-09 18:24:08 +08:00
|
|
|
void CCNode::unscheduleUpdate()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_scheduler->unscheduleUpdateForTarget(this);
|
|
|
|
if (_updateScriptHandler)
|
2012-12-10 13:48:27 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
CCScriptEngineManager::sharedManager()->getScriptEngine()->removeScriptHandler(_updateScriptHandler);
|
|
|
|
_updateScriptHandler = 0;
|
2012-12-10 13:48:27 +08:00
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
2010-07-14 11:52:27 +08:00
|
|
|
void CCNode::schedule(SEL_SCHEDULE selector)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
this->schedule(selector, 0.0f, kCCRepeatForever, 0.0f);
|
2012-03-14 14:55:17 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void CCNode::schedule(SEL_SCHEDULE selector, float interval)
|
2012-04-04 21:58:04 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
this->schedule(selector, interval, kCCRepeatForever, 0.0f);
|
2010-07-14 11:52:27 +08:00
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void CCNode::schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCAssert( selector, "Argument must be non-nil");
|
|
|
|
CCAssert( interval >=0, "Argument must be positive");
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_scheduler->scheduleSelector(selector, this, interval , repeat, delay, !_running);
|
2012-03-14 14:55:17 +08:00
|
|
|
}
|
|
|
|
|
2012-06-08 13:55:28 +08:00
|
|
|
void CCNode::scheduleOnce(SEL_SCHEDULE selector, float delay)
|
2012-04-04 21:58:04 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
this->schedule(selector, 0.0f, 0, delay);
|
2010-07-14 11:52:27 +08:00
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2010-07-14 11:52:27 +08:00
|
|
|
void CCNode::unschedule(SEL_SCHEDULE selector)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
// explicit nil handling
|
|
|
|
if (selector == 0)
|
|
|
|
return;
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_scheduler->unscheduleSelector(selector, this);
|
2010-07-14 11:52:27 +08:00
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
|
|
|
|
void CCNode::unscheduleAllSelectors()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_scheduler->unscheduleAllForTarget(this);
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::resumeSchedulerAndActions()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_scheduler->resumeTarget(this);
|
|
|
|
_actionManager->resumeTarget(this);
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::pauseSchedulerAndActions()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_scheduler->pauseTarget(this);
|
|
|
|
_actionManager->pauseTarget(this);
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
2012-11-14 18:05:15 +08:00
|
|
|
// override me
|
|
|
|
void CCNode::update(float fDelta)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_updateScriptHandler)
|
2012-12-10 13:48:27 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
CCScriptEngineManager::sharedManager()->getScriptEngine()->executeSchedule(_updateScriptHandler, fDelta, this);
|
2012-12-10 13:48:27 +08:00
|
|
|
}
|
2013-06-04 17:38:43 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_componentContainer && !_componentContainer->isEmpty())
|
2013-06-04 17:38:43 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_componentContainer->visit(fDelta);
|
2013-06-04 17:38:43 +08:00
|
|
|
}
|
2012-11-14 18:05:15 +08:00
|
|
|
}
|
|
|
|
|
2011-03-07 17:11:57 +08:00
|
|
|
CCAffineTransform CCNode::nodeToParentTransform(void)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_transformDirty)
|
2012-06-08 14:17:39 +08:00
|
|
|
{
|
2012-04-04 21:58:04 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// Translate values
|
2013-06-15 14:03:30 +08:00
|
|
|
float x = _position.x;
|
|
|
|
float y = _position.y;
|
2012-04-04 21:58:04 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_ignoreAnchorPointForPosition)
|
2012-06-08 14:17:39 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
x += _anchorPointInPoints.x;
|
|
|
|
y += _anchorPointInPoints.y;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2012-04-04 21:58:04 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// Rotation values
|
2012-11-14 18:05:15 +08:00
|
|
|
// Change rotation code to handle X and Y
|
|
|
|
// If we skew with the exact same value for both x and y then we're simply just rotating
|
|
|
|
float cx = 1, sx = 0, cy = 1, sy = 0;
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_rotationX || _rotationY)
|
2012-06-08 14:17:39 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
float radiansX = -CC_DEGREES_TO_RADIANS(_rotationX);
|
|
|
|
float radiansY = -CC_DEGREES_TO_RADIANS(_rotationY);
|
2012-11-14 18:05:15 +08:00
|
|
|
cx = cosf(radiansX);
|
|
|
|
sx = sinf(radiansX);
|
|
|
|
cy = cosf(radiansY);
|
|
|
|
sy = sinf(radiansY);
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2012-04-04 21:58:04 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
bool needsSkewMatrix = ( _skewX || _skewY );
|
2012-04-04 21:58:04 +08:00
|
|
|
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// optimization:
|
|
|
|
// inline anchor point calculation if skew is not needed
|
2012-11-14 18:05:15 +08:00
|
|
|
// Adjusted transform calculation for rotational skew
|
2013-06-15 14:03:30 +08:00
|
|
|
if (! needsSkewMatrix && !_anchorPointInPoints.equals(CCPointZero))
|
2012-06-08 14:17:39 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
x += cy * -_anchorPointInPoints.x * _scaleX + -sx * -_anchorPointInPoints.y * _scaleY;
|
|
|
|
y += sy * -_anchorPointInPoints.x * _scaleX + cx * -_anchorPointInPoints.y * _scaleY;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2012-04-04 21:58:04 +08:00
|
|
|
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// Build Transform Matrix
|
2012-11-14 18:05:15 +08:00
|
|
|
// Adjusted transform calculation for rotational skew
|
2013-06-15 14:03:30 +08:00
|
|
|
_transform = CCAffineTransformMake( cy * _scaleX, sy * _scaleX,
|
|
|
|
-sx * _scaleY, cx * _scaleY,
|
2012-04-19 14:35:52 +08:00
|
|
|
x, y );
|
2012-04-04 21:58:04 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// XXX: Try to inline skew
|
|
|
|
// If skew is needed, apply skew and then anchor point
|
2012-06-08 14:17:39 +08:00
|
|
|
if (needsSkewMatrix)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
CCAffineTransform skewMatrix = CCAffineTransformMake(1.0f, tanf(CC_DEGREES_TO_RADIANS(_skewY)),
|
|
|
|
tanf(CC_DEGREES_TO_RADIANS(_skewX)), 1.0f,
|
2012-04-19 14:35:52 +08:00
|
|
|
0.0f, 0.0f );
|
2013-06-15 14:03:30 +08:00
|
|
|
_transform = CCAffineTransformConcat(skewMatrix, _transform);
|
2012-04-04 21:58:04 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// adjust anchor point
|
2013-06-15 14:03:30 +08:00
|
|
|
if (!_anchorPointInPoints.equals(CCPointZero))
|
2012-06-08 14:17:39 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_transform = CCAffineTransformTranslate(_transform, -_anchorPointInPoints.x, -_anchorPointInPoints.y);
|
2012-06-08 14:17:39 +08:00
|
|
|
}
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2013-02-22 16:01:49 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
if (_additionalTransformDirty)
|
2013-02-22 16:01:49 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_transform = CCAffineTransformConcat(_transform, _additionalTransform);
|
|
|
|
_additionalTransformDirty = false;
|
2013-02-22 16:01:49 +08:00
|
|
|
}
|
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
_transformDirty = false;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2012-04-04 21:58:04 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
return _transform;
|
2010-07-19 16:45:53 +08:00
|
|
|
}
|
2013-02-22 16:01:49 +08:00
|
|
|
|
|
|
|
void CCNode::setAdditionalTransform(const CCAffineTransform& additionalTransform)
|
2013-02-20 22:33:28 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_additionalTransform = additionalTransform;
|
|
|
|
_transformDirty = true;
|
|
|
|
_additionalTransformDirty = true;
|
2013-02-20 22:33:28 +08:00
|
|
|
}
|
2013-02-22 16:01:49 +08:00
|
|
|
|
2011-03-07 17:11:57 +08:00
|
|
|
CCAffineTransform CCNode::parentToNodeTransform(void)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
if ( _inverseDirty ) {
|
|
|
|
_inverse = CCAffineTransformInvert(this->nodeToParentTransform());
|
|
|
|
_inverseDirty = false;
|
2012-04-19 14:35:52 +08:00
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
return _inverse;
|
2010-07-19 16:45:53 +08:00
|
|
|
}
|
|
|
|
|
2011-03-07 17:11:57 +08:00
|
|
|
CCAffineTransform CCNode::nodeToWorldTransform()
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCAffineTransform t = this->nodeToParentTransform();
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2013-06-15 14:03:30 +08:00
|
|
|
for (CCNode *p = _parent; p != NULL; p = p->getParent())
|
2012-04-19 14:35:52 +08:00
|
|
|
t = CCAffineTransformConcat(t, p->nodeToParentTransform());
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
return t;
|
2010-07-19 16:45:53 +08:00
|
|
|
}
|
2010-07-21 17:40:10 +08:00
|
|
|
|
2011-03-07 17:11:57 +08:00
|
|
|
CCAffineTransform CCNode::worldToNodeTransform(void)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
return CCAffineTransformInvert(this->nodeToWorldTransform());
|
2010-07-19 16:45:53 +08:00
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2011-08-17 21:19:57 +08:00
|
|
|
CCPoint CCNode::convertToNodeSpace(const CCPoint& worldPoint)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCPoint ret = CCPointApplyAffineTransform(worldPoint, worldToNodeTransform());
|
|
|
|
return ret;
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
2011-08-17 21:19:57 +08:00
|
|
|
CCPoint CCNode::convertToWorldSpace(const CCPoint& nodePoint)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCPoint ret = CCPointApplyAffineTransform(nodePoint, nodeToWorldTransform());
|
|
|
|
return ret;
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
2011-08-17 21:19:57 +08:00
|
|
|
CCPoint CCNode::convertToNodeSpaceAR(const CCPoint& worldPoint)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCPoint nodePoint = convertToNodeSpace(worldPoint);
|
2013-06-15 14:03:30 +08:00
|
|
|
return ccpSub(nodePoint, _anchorPointInPoints);
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
|
|
|
|
2011-08-17 21:19:57 +08:00
|
|
|
CCPoint CCNode::convertToWorldSpaceAR(const CCPoint& nodePoint)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
CCPoint pt = ccpAdd(nodePoint, _anchorPointInPoints);
|
2012-04-19 14:35:52 +08:00
|
|
|
return convertToWorldSpace(pt);
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
2012-03-14 14:55:17 +08:00
|
|
|
|
2011-08-17 21:19:57 +08:00
|
|
|
CCPoint CCNode::convertToWindowSpace(const CCPoint& nodePoint)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-04-19 14:35:52 +08:00
|
|
|
CCPoint worldPoint = this->convertToWorldSpace(nodePoint);
|
|
|
|
return CCDirector::sharedDirector()->convertToUI(worldPoint);
|
2010-07-20 13:49:13 +08:00
|
|
|
}
|
2010-07-09 18:24:08 +08:00
|
|
|
|
2011-03-07 17:11:57 +08:00
|
|
|
// convenience methods which take a CCTouch instead of CCPoint
|
|
|
|
CCPoint CCNode::convertTouchToNodeSpace(CCTouch *touch)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-07-31 17:41:53 +08:00
|
|
|
CCPoint point = touch->getLocation();
|
2012-04-19 14:35:52 +08:00
|
|
|
return this->convertToNodeSpace(point);
|
2010-07-30 16:35:07 +08:00
|
|
|
}
|
2011-03-07 17:11:57 +08:00
|
|
|
CCPoint CCNode::convertTouchToNodeSpaceAR(CCTouch *touch)
|
2010-07-09 18:24:08 +08:00
|
|
|
{
|
2012-07-31 17:41:53 +08:00
|
|
|
CCPoint point = touch->getLocation();
|
2012-04-19 14:35:52 +08:00
|
|
|
return this->convertToNodeSpaceAR(point);
|
2010-07-09 18:24:08 +08:00
|
|
|
}
|
2010-07-30 16:35:07 +08:00
|
|
|
|
2012-11-09 12:08:18 +08:00
|
|
|
void CCNode::updateTransform()
|
|
|
|
{
|
|
|
|
// Recursively iterate over children
|
2013-06-15 14:03:30 +08:00
|
|
|
arrayMakeObjectsPerformSelector(_children, updateTransform, CCNode*);
|
2012-10-30 10:24:28 +08:00
|
|
|
}
|
|
|
|
|
2013-06-04 17:38:43 +08:00
|
|
|
CCComponent* CCNode::getComponent(const char *pName) const
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _componentContainer->get(pName);
|
2013-06-04 17:38:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CCNode::addComponent(CCComponent *pComponent)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _componentContainer->add(pComponent);
|
2013-06-04 17:38:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool CCNode::removeComponent(const char *pName)
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
return _componentContainer->remove(pName);
|
2013-06-04 17:38:43 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNode::removeAllComponents()
|
|
|
|
{
|
2013-06-15 14:03:30 +08:00
|
|
|
_componentContainer->removeAll();
|
2013-06-04 17:38:43 +08:00
|
|
|
}
|
|
|
|
|
2013-02-27 09:38:30 +08:00
|
|
|
// CCNodeRGBA
|
2013-02-27 14:48:19 +08:00
|
|
|
CCNodeRGBA::CCNodeRGBA()
|
2013-03-01 16:14:10 +08:00
|
|
|
: _displayedOpacity(255)
|
2013-02-28 11:55:36 +08:00
|
|
|
, _realOpacity(255)
|
2013-03-01 16:14:10 +08:00
|
|
|
, _displayedColor(ccWHITE)
|
|
|
|
, _realColor(ccWHITE)
|
2013-02-27 14:48:19 +08:00
|
|
|
, _cascadeColorEnabled(false)
|
|
|
|
, _cascadeOpacityEnabled(false)
|
|
|
|
{}
|
|
|
|
|
|
|
|
CCNodeRGBA::~CCNodeRGBA() {}
|
2013-02-27 09:38:30 +08:00
|
|
|
|
|
|
|
bool CCNodeRGBA::init()
|
|
|
|
{
|
|
|
|
if (CCNode::init())
|
|
|
|
{
|
2013-02-27 14:48:19 +08:00
|
|
|
_displayedOpacity = _realOpacity = 255;
|
|
|
|
_displayedColor = _realColor = ccWHITE;
|
|
|
|
_cascadeOpacityEnabled = _cascadeColorEnabled = false;
|
2013-02-27 09:38:30 +08:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLubyte CCNodeRGBA::getOpacity(void)
|
|
|
|
{
|
2013-02-27 14:48:19 +08:00
|
|
|
return _realOpacity;
|
2013-02-27 09:38:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GLubyte CCNodeRGBA::getDisplayedOpacity(void)
|
|
|
|
{
|
2013-02-27 14:48:19 +08:00
|
|
|
return _displayedOpacity;
|
2013-02-27 09:38:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void CCNodeRGBA::setOpacity(GLubyte opacity)
|
|
|
|
{
|
2013-02-27 14:48:19 +08:00
|
|
|
_displayedOpacity = _realOpacity = opacity;
|
2013-02-27 09:38:30 +08:00
|
|
|
|
2013-02-27 14:48:19 +08:00
|
|
|
if (_cascadeOpacityEnabled)
|
|
|
|
{
|
2013-02-27 09:38:30 +08:00
|
|
|
GLubyte parentOpacity = 255;
|
2013-06-15 14:03:30 +08:00
|
|
|
CCRGBAProtocol* pParent = dynamic_cast<CCRGBAProtocol*>(_parent);
|
2013-02-27 09:38:30 +08:00
|
|
|
if (pParent && pParent->isCascadeOpacityEnabled())
|
|
|
|
{
|
|
|
|
parentOpacity = pParent->getDisplayedOpacity();
|
|
|
|
}
|
|
|
|
this->updateDisplayedOpacity(parentOpacity);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCNodeRGBA::updateDisplayedOpacity(GLubyte parentOpacity)
|
|
|
|
{
|
2013-02-27 14:48:19 +08:00
|
|
|
_displayedOpacity = _realOpacity * parentOpacity/255.0;
|
2013-02-27 09:38:30 +08:00
|
|
|
|
2013-02-27 18:21:35 +08:00
|
|
|
if (_cascadeOpacityEnabled)
|
2013-02-27 14:48:19 +08:00
|
|
|
{
|
2013-02-27 09:38:30 +08:00
|
|
|
CCObject* pObj;
|
2013-06-15 14:03:30 +08:00
|
|
|
CCARRAY_FOREACH(_children, pObj)
|
2013-02-27 14:48:19 +08:00
|
|
|
{
|
|
|
|
CCRGBAProtocol* item = dynamic_cast<CCRGBAProtocol*>(pObj);
|
|
|
|
if (item)
|
|
|
|
{
|
|
|
|
item->updateDisplayedOpacity(_displayedOpacity);
|
2013-02-27 09:38:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-27 15:30:49 +08:00
|
|
|
bool CCNodeRGBA::isCascadeOpacityEnabled(void)
|
|
|
|
{
|
|
|
|
return _cascadeOpacityEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCNodeRGBA::setCascadeOpacityEnabled(bool cascadeOpacityEnabled)
|
|
|
|
{
|
|
|
|
_cascadeOpacityEnabled = cascadeOpacityEnabled;
|
|
|
|
}
|
|
|
|
|
2013-02-27 09:38:30 +08:00
|
|
|
const ccColor3B& CCNodeRGBA::getColor(void)
|
|
|
|
{
|
|
|
|
return _realColor;
|
|
|
|
}
|
|
|
|
|
2013-02-27 14:48:19 +08:00
|
|
|
const ccColor3B& CCNodeRGBA::getDisplayedColor()
|
2013-02-27 09:38:30 +08:00
|
|
|
{
|
|
|
|
return _displayedColor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCNodeRGBA::setColor(const ccColor3B& color)
|
|
|
|
{
|
|
|
|
_displayedColor = _realColor = color;
|
|
|
|
|
2013-02-27 14:48:19 +08:00
|
|
|
if (_cascadeColorEnabled)
|
|
|
|
{
|
2013-02-27 09:38:30 +08:00
|
|
|
ccColor3B parentColor = ccWHITE;
|
2013-06-15 14:03:30 +08:00
|
|
|
CCRGBAProtocol *parent = dynamic_cast<CCRGBAProtocol*>(_parent);
|
2013-02-27 14:48:19 +08:00
|
|
|
if (parent && parent->isCascadeColorEnabled())
|
|
|
|
{
|
2013-02-27 18:21:35 +08:00
|
|
|
parentColor = parent->getDisplayedColor();
|
2013-02-27 14:48:19 +08:00
|
|
|
}
|
2013-02-27 18:21:35 +08:00
|
|
|
|
2013-02-28 11:55:36 +08:00
|
|
|
updateDisplayedColor(parentColor);
|
2013-02-27 09:38:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-27 14:48:19 +08:00
|
|
|
void CCNodeRGBA::updateDisplayedColor(const ccColor3B& parentColor)
|
2013-02-27 09:38:30 +08:00
|
|
|
{
|
|
|
|
_displayedColor.r = _realColor.r * parentColor.r/255.0;
|
|
|
|
_displayedColor.g = _realColor.g * parentColor.g/255.0;
|
|
|
|
_displayedColor.b = _realColor.b * parentColor.b/255.0;
|
|
|
|
|
2013-02-27 14:48:19 +08:00
|
|
|
if (_cascadeColorEnabled)
|
|
|
|
{
|
|
|
|
CCObject *obj = NULL;
|
2013-06-15 14:03:30 +08:00
|
|
|
CCARRAY_FOREACH(_children, obj)
|
2013-02-27 14:48:19 +08:00
|
|
|
{
|
|
|
|
CCRGBAProtocol *item = dynamic_cast<CCRGBAProtocol*>(obj);
|
|
|
|
if (item)
|
|
|
|
{
|
|
|
|
item->updateDisplayedColor(_displayedColor);
|
2013-02-27 09:38:30 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-01-17 11:20:25 +08:00
|
|
|
|
2013-02-27 15:30:49 +08:00
|
|
|
bool CCNodeRGBA::isCascadeColorEnabled(void)
|
|
|
|
{
|
|
|
|
return _cascadeColorEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CCNodeRGBA::setCascadeColorEnabled(bool cascadeColorEnabled)
|
|
|
|
{
|
|
|
|
_cascadeColorEnabled = cascadeColorEnabled;
|
|
|
|
}
|
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
NS_CC_END
|