mirror of https://github.com/axmolengine/axmol.git
Merge pull request #3177 from dumganhar/ricardoquesada-sanityzing_code
Merge PR https://github.com/cocos2d/cocos2d-x/pull/3170
This commit is contained in:
commit
7d4b798ae3
|
@ -102,7 +102,7 @@ Node::Node(void)
|
|||
_componentContainer = new ComponentContainer(this);
|
||||
}
|
||||
|
||||
Node::~Node(void)
|
||||
Node::~Node()
|
||||
{
|
||||
CCLOGINFO( "cocos2d: deallocing: %p", this );
|
||||
|
||||
|
@ -305,12 +305,12 @@ void Node::setPosition(float x, float y)
|
|||
setPosition(Point(x, y));
|
||||
}
|
||||
|
||||
float Node::getPositionX(void) const
|
||||
float Node::getPositionX() const
|
||||
{
|
||||
return _position.x;
|
||||
}
|
||||
|
||||
float Node::getPositionY(void) const
|
||||
float Node::getPositionY() const
|
||||
{
|
||||
return _position.y;
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ Array* Node::getChildren()
|
|||
return _children;
|
||||
}
|
||||
|
||||
unsigned int Node::getChildrenCount(void) const
|
||||
unsigned int Node::getChildrenCount() const
|
||||
{
|
||||
return _children ? _children->count() : 0;
|
||||
}
|
||||
|
@ -513,12 +513,18 @@ void Node::setShaderProgram(GLProgram *pShaderProgram)
|
|||
_shaderProgram = pShaderProgram;
|
||||
}
|
||||
|
||||
Rect Node::boundingBox()
|
||||
Rect Node::getBoundingBox() const
|
||||
{
|
||||
Rect rect = Rect(0, 0, _contentSize.width, _contentSize.height);
|
||||
return RectApplyAffineTransform(rect, nodeToParentTransform());
|
||||
return RectApplyAffineTransform(rect, getNodeToParentTransform());
|
||||
}
|
||||
|
||||
Rect Node::boundingBox() const
|
||||
{
|
||||
return getBoundingBox();
|
||||
}
|
||||
|
||||
|
||||
Node * Node::create(void)
|
||||
{
|
||||
Node * pRet = new Node();
|
||||
|
@ -882,7 +888,7 @@ void Node::transform()
|
|||
kmMat4 transfrom4x4;
|
||||
|
||||
// Convert 3x3 into 4x4 matrix
|
||||
AffineTransform tmpAffine = this->nodeToParentTransform();
|
||||
AffineTransform tmpAffine = this->getNodeToParentTransform();
|
||||
CGAffineToGL(&tmpAffine, transfrom4x4.mat);
|
||||
|
||||
// Update Z vertex manually
|
||||
|
@ -1149,7 +1155,7 @@ void Node::update(float fDelta)
|
|||
}
|
||||
}
|
||||
|
||||
AffineTransform Node::nodeToParentTransform(void)
|
||||
AffineTransform Node::getNodeToParentTransform() const
|
||||
{
|
||||
if (_transformDirty)
|
||||
{
|
||||
|
@ -1225,6 +1231,12 @@ AffineTransform Node::nodeToParentTransform(void)
|
|||
return _transform;
|
||||
}
|
||||
|
||||
// XXX deprecated
|
||||
AffineTransform Node::nodeToParentTransform() const
|
||||
{
|
||||
return getNodeToParentTransform();
|
||||
}
|
||||
|
||||
void Node::setAdditionalTransform(const AffineTransform& additionalTransform)
|
||||
{
|
||||
_additionalTransform = additionalTransform;
|
||||
|
@ -1232,68 +1244,86 @@ void Node::setAdditionalTransform(const AffineTransform& additionalTransform)
|
|||
_additionalTransformDirty = true;
|
||||
}
|
||||
|
||||
AffineTransform Node::parentToNodeTransform(void)
|
||||
AffineTransform Node::getParentToNodeTransform() const
|
||||
{
|
||||
if ( _inverseDirty ) {
|
||||
_inverse = AffineTransformInvert(this->nodeToParentTransform());
|
||||
_inverse = AffineTransformInvert(this->getNodeToParentTransform());
|
||||
_inverseDirty = false;
|
||||
}
|
||||
|
||||
return _inverse;
|
||||
}
|
||||
|
||||
AffineTransform Node::nodeToWorldTransform()
|
||||
// XXX deprecated
|
||||
AffineTransform Node::parentToNodeTransform() const
|
||||
{
|
||||
AffineTransform t = this->nodeToParentTransform();
|
||||
return getParentToNodeTransform();
|
||||
}
|
||||
|
||||
AffineTransform Node::getNodeToWorldTransform() const
|
||||
{
|
||||
AffineTransform t = this->getNodeToParentTransform();
|
||||
|
||||
for (Node *p = _parent; p != NULL; p = p->getParent())
|
||||
t = AffineTransformConcat(t, p->nodeToParentTransform());
|
||||
t = AffineTransformConcat(t, p->getNodeToParentTransform());
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
AffineTransform Node::worldToNodeTransform(void)
|
||||
// XXX deprecated
|
||||
AffineTransform Node::nodeToWorldTransform() const
|
||||
{
|
||||
return AffineTransformInvert(this->nodeToWorldTransform());
|
||||
return getNodeToWorldTransform();
|
||||
}
|
||||
|
||||
Point Node::convertToNodeSpace(const Point& worldPoint)
|
||||
AffineTransform Node::getWorldToNodeTransform() const
|
||||
{
|
||||
Point ret = PointApplyAffineTransform(worldPoint, worldToNodeTransform());
|
||||
return AffineTransformInvert(this->getNodeToWorldTransform());
|
||||
}
|
||||
|
||||
// XXX deprecated
|
||||
AffineTransform Node::worldToNodeTransform() const
|
||||
{
|
||||
return getWorldToNodeTransform();
|
||||
}
|
||||
|
||||
Point Node::convertToNodeSpace(const Point& worldPoint) const
|
||||
{
|
||||
Point ret = PointApplyAffineTransform(worldPoint, getWorldToNodeTransform());
|
||||
return ret;
|
||||
}
|
||||
|
||||
Point Node::convertToWorldSpace(const Point& nodePoint)
|
||||
Point Node::convertToWorldSpace(const Point& nodePoint) const
|
||||
{
|
||||
Point ret = PointApplyAffineTransform(nodePoint, nodeToWorldTransform());
|
||||
Point ret = PointApplyAffineTransform(nodePoint, getNodeToWorldTransform());
|
||||
return ret;
|
||||
}
|
||||
|
||||
Point Node::convertToNodeSpaceAR(const Point& worldPoint)
|
||||
Point Node::convertToNodeSpaceAR(const Point& worldPoint) const
|
||||
{
|
||||
Point nodePoint = convertToNodeSpace(worldPoint);
|
||||
return nodePoint - _anchorPointInPoints;
|
||||
}
|
||||
|
||||
Point Node::convertToWorldSpaceAR(const Point& nodePoint)
|
||||
Point Node::convertToWorldSpaceAR(const Point& nodePoint) const
|
||||
{
|
||||
Point pt = nodePoint + _anchorPointInPoints;
|
||||
return convertToWorldSpace(pt);
|
||||
}
|
||||
|
||||
Point Node::convertToWindowSpace(const Point& nodePoint)
|
||||
Point Node::convertToWindowSpace(const Point& nodePoint) const
|
||||
{
|
||||
Point worldPoint = this->convertToWorldSpace(nodePoint);
|
||||
return Director::getInstance()->convertToUI(worldPoint);
|
||||
}
|
||||
|
||||
// convenience methods which take a Touch instead of Point
|
||||
Point Node::convertTouchToNodeSpace(Touch *touch)
|
||||
Point Node::convertTouchToNodeSpace(Touch *touch) const
|
||||
{
|
||||
Point point = touch->getLocation();
|
||||
return this->convertToNodeSpace(point);
|
||||
}
|
||||
Point Node::convertTouchToNodeSpaceAR(Touch *touch)
|
||||
Point Node::convertTouchToNodeSpaceAR(Touch *touch) const
|
||||
{
|
||||
Point point = touch->getLocation();
|
||||
return this->convertToNodeSpaceAR(point);
|
||||
|
|
|
@ -464,7 +464,7 @@ public:
|
|||
*
|
||||
* @param fRotationX The X rotation in degrees which performs a horizontal rotational skew.
|
||||
*/
|
||||
virtual void setRotationX(float fRotaionX);
|
||||
virtual void setRotationX(float rotaionX);
|
||||
/**
|
||||
* Gets the X rotation (angle) of the node in degrees which performs a horizontal rotation skew.
|
||||
*
|
||||
|
@ -483,7 +483,7 @@ public:
|
|||
*
|
||||
* @param fRotationY The Y rotation in degrees.
|
||||
*/
|
||||
virtual void setRotationY(float fRotationY);
|
||||
virtual void setRotationY(float rotationY);
|
||||
/**
|
||||
* Gets the Y rotation (angle) of the node in degrees which performs a vertical rotational skew.
|
||||
*
|
||||
|
@ -504,7 +504,7 @@ public:
|
|||
*
|
||||
* @param uOrderOfArrival The arrival order.
|
||||
*/
|
||||
virtual void setOrderOfArrival(unsigned int uOrderOfArrival);
|
||||
virtual void setOrderOfArrival(unsigned int orderOfArrival);
|
||||
/**
|
||||
* Returns the arrival order, indecates which children is added previously.
|
||||
*
|
||||
|
@ -520,7 +520,7 @@ public:
|
|||
*
|
||||
* @param glServerState The state of OpenGL server side.
|
||||
*/
|
||||
virtual void setGLServerState(ccGLServerState glServerState);
|
||||
virtual void setGLServerState(ccGLServerState serverState);
|
||||
/**
|
||||
* Returns the state of OpenGL server side.
|
||||
*
|
||||
|
@ -612,7 +612,7 @@ public:
|
|||
*
|
||||
* @return The amount of children.
|
||||
*/
|
||||
unsigned int getChildrenCount(void) const;
|
||||
unsigned int getChildrenCount() const;
|
||||
|
||||
/**
|
||||
* Sets the parent node
|
||||
|
@ -720,7 +720,7 @@ public:
|
|||
*
|
||||
* @param A Grid object that is used when applying effects
|
||||
*/
|
||||
virtual void setGrid(GridBase *pGrid);
|
||||
virtual void setGrid(GridBase *grid);
|
||||
|
||||
/// @} end of Grid
|
||||
|
||||
|
@ -769,7 +769,7 @@ public:
|
|||
*
|
||||
* @param A interger that indentifies the node.
|
||||
*/
|
||||
virtual void setTag(int nTag);
|
||||
virtual void setTag(int tag);
|
||||
|
||||
/**
|
||||
* Returns a custom user data pointer
|
||||
|
@ -788,7 +788,7 @@ public:
|
|||
*
|
||||
* @param A custom user data pointer
|
||||
*/
|
||||
virtual void setUserData(void *pUserData);
|
||||
virtual void setUserData(void *userData);
|
||||
|
||||
/**
|
||||
* Returns a user assigned Object
|
||||
|
@ -808,7 +808,7 @@ public:
|
|||
*
|
||||
* @param A user assigned Object
|
||||
*/
|
||||
virtual void setUserObject(Object *pUserObject);
|
||||
virtual void setUserObject(Object *userObject);
|
||||
|
||||
/// @} end of Tag & User Data
|
||||
|
||||
|
@ -832,7 +832,7 @@ public:
|
|||
*
|
||||
* @param The shader program which fetchs from ShaderCache.
|
||||
*/
|
||||
virtual void setShaderProgram(GLProgram *pShaderProgram);
|
||||
virtual void setShaderProgram(GLProgram *shaderProgram);
|
||||
/// @} end of Shader Program
|
||||
|
||||
|
||||
|
@ -861,7 +861,7 @@ public:
|
|||
/**
|
||||
* Schedules for lua script.
|
||||
*/
|
||||
void scheduleUpdateWithPriorityLua(int nHandler, int priority);
|
||||
void scheduleUpdateWithPriorityLua(int handler, int priority);
|
||||
|
||||
/// @} end Script Bindings
|
||||
|
||||
|
@ -903,7 +903,7 @@ public:
|
|||
/**
|
||||
* Stops all running actions and schedulers
|
||||
*/
|
||||
virtual void cleanup(void);
|
||||
virtual void cleanup();
|
||||
|
||||
/**
|
||||
* Override this method to draw your own node.
|
||||
|
@ -915,12 +915,12 @@ public:
|
|||
* AND YOU SHOULD NOT DISABLE THEM AFTER DRAWING YOUR NODE
|
||||
* But if you enable any other GL state, you should disable it after drawing your node.
|
||||
*/
|
||||
virtual void draw(void);
|
||||
virtual void draw();
|
||||
|
||||
/**
|
||||
* Visits this node's children and draw them recursively.
|
||||
*/
|
||||
virtual void visit(void);
|
||||
virtual void visit();
|
||||
|
||||
|
||||
/**
|
||||
|
@ -932,7 +932,10 @@ public:
|
|||
*
|
||||
* @return A "local" axis aligned boudning box of the node.
|
||||
*/
|
||||
Rect boundingBox(void);
|
||||
virtual Rect getBoundingBox() const;
|
||||
|
||||
/** @deprecated Use getBoundingBox instead */
|
||||
CC_DEPRECATED_ATTRIBUTE Rect boundingBox() const;
|
||||
|
||||
/// @{
|
||||
/// @name Actions
|
||||
|
@ -965,7 +968,7 @@ public:
|
|||
/**
|
||||
* Stops and removes all actions from the running action list .
|
||||
*/
|
||||
void stopAllActions(void);
|
||||
void stopAllActions();
|
||||
|
||||
/**
|
||||
* Stops and removes an action from the running action list.
|
||||
|
@ -1000,7 +1003,7 @@ public:
|
|||
*
|
||||
* @return The number of actions that are running plus the ones that are schedule to run
|
||||
*/
|
||||
unsigned int numberOfRunningActions(void);
|
||||
unsigned int numberOfRunningActions();
|
||||
|
||||
/// @} end of Actions
|
||||
|
||||
|
@ -1136,13 +1139,13 @@ public:
|
|||
/**
|
||||
* Performs OpenGL view-matrix transformation based on position, scale, rotation and other attributes.
|
||||
*/
|
||||
void transform(void);
|
||||
void transform();
|
||||
/**
|
||||
* Performs OpenGL view-matrix transformation of it's ancestors.
|
||||
* Generally the ancestors are already transformed, but in certain cases (eg: attaching a FBO)
|
||||
* It's necessary to transform the ancestors again.
|
||||
*/
|
||||
void transformAncestors(void);
|
||||
void transformAncestors();
|
||||
/**
|
||||
* Calls children's updateTransform() method recursively.
|
||||
*
|
||||
|
@ -1150,29 +1153,41 @@ public:
|
|||
* As the result, you apply SpriteBatchNode's optimization on your customed Node.
|
||||
* e.g., batchNode->addChild(myCustomNode), while you can only addChild(sprite) before.
|
||||
*/
|
||||
virtual void updateTransform(void);
|
||||
virtual void updateTransform();
|
||||
|
||||
/**
|
||||
* Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
|
||||
* The matrix is in Pixels.
|
||||
*/
|
||||
virtual AffineTransform nodeToParentTransform(void);
|
||||
virtual AffineTransform getNodeToParentTransform() const;
|
||||
|
||||
/** @deprecated use getNodeToParentTransform() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE virtual AffineTransform nodeToParentTransform() const;
|
||||
|
||||
/**
|
||||
* Returns the matrix that transform parent's space coordinates to the node's (local) space coordinates.
|
||||
* The matrix is in Pixels.
|
||||
*/
|
||||
virtual AffineTransform parentToNodeTransform(void);
|
||||
virtual AffineTransform getParentToNodeTransform() const;
|
||||
|
||||
/** @deprecated Use getParentToNodeTransform() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE virtual AffineTransform parentToNodeTransform() const;
|
||||
|
||||
/**
|
||||
* Returns the world affine transform matrix. The matrix is in Pixels.
|
||||
*/
|
||||
virtual AffineTransform nodeToWorldTransform(void);
|
||||
virtual AffineTransform getNodeToWorldTransform() const;
|
||||
|
||||
/** @deprecated Use getNodeToWorldTransform() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE virtual AffineTransform nodeToWorldTransform() const;
|
||||
|
||||
/**
|
||||
* Returns the inverse world affine transform matrix. The matrix is in Pixels.
|
||||
*/
|
||||
virtual AffineTransform worldToNodeTransform(void);
|
||||
virtual AffineTransform getWorldToNodeTransform() const;
|
||||
|
||||
/** @deprecated Use worldToNodeTransform() instead */
|
||||
CC_DEPRECATED_ATTRIBUTE virtual AffineTransform worldToNodeTransform() const;
|
||||
|
||||
/// @} end of Transformations
|
||||
|
||||
|
@ -1183,39 +1198,39 @@ public:
|
|||
/**
|
||||
* Converts a Point to node (local) space coordinates. The result is in Points.
|
||||
*/
|
||||
Point convertToNodeSpace(const Point& worldPoint);
|
||||
Point convertToNodeSpace(const Point& worldPoint) const;
|
||||
|
||||
/**
|
||||
* Converts a Point to world space coordinates. The result is in Points.
|
||||
*/
|
||||
Point convertToWorldSpace(const Point& nodePoint);
|
||||
Point convertToWorldSpace(const Point& nodePoint) const;
|
||||
|
||||
/**
|
||||
* Converts a Point to node (local) space coordinates. The result is in Points.
|
||||
* treating the returned/received node point as anchor relative.
|
||||
*/
|
||||
Point convertToNodeSpaceAR(const Point& worldPoint);
|
||||
Point convertToNodeSpaceAR(const Point& worldPoint) const;
|
||||
|
||||
/**
|
||||
* Converts a local Point to world space coordinates.The result is in Points.
|
||||
* treating the returned/received node point as anchor relative.
|
||||
*/
|
||||
Point convertToWorldSpaceAR(const Point& nodePoint);
|
||||
Point convertToWorldSpaceAR(const Point& nodePoint) const;
|
||||
|
||||
/**
|
||||
* convenience methods which take a Touch instead of Point
|
||||
*/
|
||||
Point convertTouchToNodeSpace(Touch * touch);
|
||||
Point convertTouchToNodeSpace(Touch * touch) const;
|
||||
|
||||
/**
|
||||
* converts a Touch (world coordinates) into a local coordinate. This method is AR (Anchor Relative).
|
||||
*/
|
||||
Point convertTouchToNodeSpaceAR(Touch * touch);
|
||||
Point convertTouchToNodeSpaceAR(Touch * touch) const;
|
||||
|
||||
/**
|
||||
* Sets the additional transform.
|
||||
*
|
||||
* @note The additional transform will be concatenated at the end of nodeToParentTransform.
|
||||
* @note The additional transform will be concatenated at the end of getNodeToParentTransform.
|
||||
* It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't).
|
||||
* @code
|
||||
// create a batchNode
|
||||
|
@ -1236,7 +1251,7 @@ public:
|
|||
spriteA->setPosition(Point(200, 200));
|
||||
|
||||
// Gets the spriteA's transform.
|
||||
AffineTransform t = spriteA->nodeToParentTransform();
|
||||
AffineTransform t = spriteA->getNodeToParentTransform();
|
||||
|
||||
// Sets the additional transform to spriteB, spriteB's postion will based on its pseudo parent i.e. spriteA.
|
||||
spriteB->setAdditionalTransform(t);
|
||||
|
@ -1245,7 +1260,7 @@ public:
|
|||
spriteA->setScale(2);
|
||||
|
||||
// Gets the spriteA's transform.
|
||||
t = spriteA->nodeToParentTransform();
|
||||
t = spriteA->getNodeToParentTransform();
|
||||
|
||||
// Sets the additional transform to spriteB, spriteB's scale will based on its pseudo parent i.e. spriteA.
|
||||
spriteB->setAdditionalTransform(t);
|
||||
|
@ -1254,7 +1269,7 @@ public:
|
|||
spriteA->setRotation(20);
|
||||
|
||||
// Gets the spriteA's transform.
|
||||
t = spriteA->nodeToParentTransform();
|
||||
t = spriteA->getNodeToParentTransform();
|
||||
|
||||
// Sets the additional transform to spriteB, spriteB's rotation will based on its pseudo parent i.e. spriteA.
|
||||
spriteB->setAdditionalTransform(t);
|
||||
|
@ -1298,7 +1313,7 @@ private:
|
|||
void detachChild(Node *child, bool doCleanup);
|
||||
|
||||
/// Convert cocos2d coordinates to UI windows coordinate.
|
||||
Point convertToWindowSpace(const Point& nodePoint);
|
||||
Point convertToWindowSpace(const Point& nodePoint) const;
|
||||
|
||||
protected:
|
||||
float _rotationX; ///< rotation angle on x-axis
|
||||
|
@ -1319,11 +1334,14 @@ protected:
|
|||
|
||||
Size _contentSize; ///< untransformed size of the node
|
||||
|
||||
|
||||
AffineTransform _additionalTransform; ///< transform
|
||||
AffineTransform _transform; ///< transform
|
||||
AffineTransform _inverse; ///< transform
|
||||
|
||||
// "cache" variables are allowed to be mutable
|
||||
mutable AffineTransform _additionalTransform; ///< transform
|
||||
mutable AffineTransform _transform; ///< transform
|
||||
mutable AffineTransform _inverse; ///< inverse transform
|
||||
mutable bool _additionalTransformDirty; ///< The flag to check whether the additional transform is dirty
|
||||
mutable bool _transformDirty; ///< transform dirty flag
|
||||
mutable bool _inverseDirty; ///< inverse transform dirty flag
|
||||
|
||||
Camera *_camera; ///< a camera
|
||||
|
||||
GridBase *_grid; ///< a grid
|
||||
|
@ -1350,9 +1368,6 @@ protected:
|
|||
|
||||
bool _running; ///< is running
|
||||
|
||||
bool _transformDirty; ///< transform dirty flag
|
||||
bool _inverseDirty; ///< transform dirty flag
|
||||
bool _additionalTransformDirty; ///< The flag to check whether the additional transform is dirty
|
||||
bool _visible; ///< is this node visible
|
||||
|
||||
bool _ignoreAnchorPointForPosition; ///< true if the Anchor Point will be (0,0) when you position the Node, false otherwise.
|
||||
|
@ -1387,23 +1402,24 @@ public:
|
|||
virtual ~NodeRGBA();
|
||||
|
||||
virtual bool init();
|
||||
|
||||
// overrides
|
||||
virtual GLubyte getOpacity() const override;
|
||||
virtual GLubyte getDisplayedOpacity() const override;
|
||||
virtual void setOpacity(GLubyte opacity) override;
|
||||
virtual void updateDisplayedOpacity(GLubyte parentOpacity) override;
|
||||
virtual bool isCascadeOpacityEnabled() const override;
|
||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled) override;
|
||||
|
||||
virtual GLubyte getOpacity() const;
|
||||
virtual GLubyte getDisplayedOpacity() const;
|
||||
virtual void setOpacity(GLubyte opacity);
|
||||
virtual void updateDisplayedOpacity(GLubyte parentOpacity);
|
||||
virtual bool isCascadeOpacityEnabled() const;
|
||||
virtual void setCascadeOpacityEnabled(bool cascadeOpacityEnabled);
|
||||
virtual const Color3B& getColor(void) const override;
|
||||
virtual const Color3B& getDisplayedColor() const override;
|
||||
virtual void setColor(const Color3B& color) override;
|
||||
virtual void updateDisplayedColor(const Color3B& parentColor) override;
|
||||
virtual bool isCascadeColorEnabled() const override;
|
||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled) override;
|
||||
|
||||
virtual const Color3B& getColor(void) const;
|
||||
virtual const Color3B& getDisplayedColor() const;
|
||||
virtual void setColor(const Color3B& color);
|
||||
virtual void updateDisplayedColor(const Color3B& parentColor);
|
||||
virtual bool isCascadeColorEnabled() const;
|
||||
virtual void setCascadeColorEnabled(bool cascadeColorEnabled);
|
||||
|
||||
virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);};
|
||||
virtual bool isOpacityModifyRGB() const { return false; };
|
||||
virtual void setOpacityModifyRGB(bool bValue) override {CC_UNUSED_PARAM(bValue);};
|
||||
virtual bool isOpacityModifyRGB() const override { return false; };
|
||||
|
||||
protected:
|
||||
GLubyte _displayedOpacity;
|
||||
|
|
|
@ -465,12 +465,12 @@ void Sprite::updateTransform(void)
|
|||
|
||||
if( ! _parent || _parent == _batchNode )
|
||||
{
|
||||
_transformToBatch = nodeToParentTransform();
|
||||
_transformToBatch = getNodeToParentTransform();
|
||||
}
|
||||
else
|
||||
{
|
||||
CCAssert( dynamic_cast<Sprite*>(_parent), "Logic error in Sprite. Parent must be a Sprite");
|
||||
_transformToBatch = AffineTransformConcat( nodeToParentTransform() , ((Sprite*)_parent)->_transformToBatch );
|
||||
_transformToBatch = AffineTransformConcat( getNodeToParentTransform() , ((Sprite*)_parent)->_transformToBatch );
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -323,7 +323,7 @@ Dictionary *Armature::getBoneDic()
|
|||
return _boneDic;
|
||||
}
|
||||
|
||||
AffineTransform Armature::nodeToParentTransform()
|
||||
AffineTransform Armature::getNodeToParentTransform() const
|
||||
{
|
||||
if (_transformDirty)
|
||||
{
|
||||
|
@ -404,7 +404,7 @@ AffineTransform Armature::nodeToParentTransform()
|
|||
void Armature::updateOffsetPoint()
|
||||
{
|
||||
// Set contentsize and Calculate anchor point.
|
||||
Rect rect = boundingBox();
|
||||
Rect rect = getBoundingBox();
|
||||
setContentSize(rect.size);
|
||||
_offsetPoint = Point(-rect.origin.x, -rect.origin.y);
|
||||
setAnchorPoint(Point(_offsetPoint.x / rect.size.width, _offsetPoint.y / rect.size.height));
|
||||
|
@ -523,7 +523,7 @@ void Armature::visit()
|
|||
kmGLPopMatrix();
|
||||
}
|
||||
|
||||
Rect Armature::boundingBox()
|
||||
Rect Armature::getBoundingBox() const
|
||||
{
|
||||
float minx, miny, maxx, maxy = 0;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public:
|
|||
|
||||
public:
|
||||
Armature();
|
||||
~Armature(void);
|
||||
virtual ~Armature(void);
|
||||
|
||||
/**
|
||||
* Init the empty armature
|
||||
|
@ -101,27 +101,24 @@ public:
|
|||
* @return Armature's bone dictionary
|
||||
*/
|
||||
Dictionary *getBoneDic();
|
||||
|
||||
/**
|
||||
* This boundingBox will calculate all bones' boundingBox every time
|
||||
*/
|
||||
virtual Rect boundingBox();
|
||||
|
||||
Bone *getBoneAtPoint(float x, float y);
|
||||
|
||||
virtual void visit();
|
||||
virtual void update(float dt);
|
||||
virtual void draw();
|
||||
|
||||
virtual AffineTransform nodeToParentTransform();
|
||||
|
||||
/**
|
||||
* Set contentsize and Calculate anchor point.
|
||||
*/
|
||||
virtual void updateOffsetPoint();
|
||||
|
||||
inline void setBlendFunc(const BlendFunc& blendFunc) { _blendFunc = blendFunc; }
|
||||
inline const BlendFunc& getBlendFunc(void) const { return _blendFunc; }
|
||||
// overrides
|
||||
virtual void visit() override;
|
||||
virtual void update(float dt) override;
|
||||
virtual void draw() override;
|
||||
virtual AffineTransform getNodeToParentTransform() const override;
|
||||
/** This boundingBox will calculate all bones' boundingBox every time */
|
||||
virtual Rect getBoundingBox() const override;
|
||||
inline void setBlendFunc(const BlendFunc& blendFunc) override { _blendFunc = blendFunc; }
|
||||
inline const BlendFunc& getBlendFunc(void) const override { return _blendFunc; }
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -303,7 +303,7 @@ Size DisplayManager::getContentSize()
|
|||
Rect DisplayManager::getBoundingBox()
|
||||
{
|
||||
CS_RETURN_IF(!_displayRenderNode) Rect(0, 0, 0, 0);
|
||||
return _displayRenderNode->boundingBox();
|
||||
return _displayRenderNode->getBoundingBox();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -71,7 +71,7 @@ void Skin::setSkinData(const BaseData &var)
|
|||
setRotation(CC_RADIANS_TO_DEGREES(_skinData.skewX));
|
||||
setPosition(Point(_skinData.x, _skinData.y));
|
||||
|
||||
_skinTransform = nodeToParentTransform();
|
||||
_skinTransform = getNodeToParentTransform();
|
||||
}
|
||||
|
||||
const BaseData &Skin::getSkinData() const
|
||||
|
|
|
@ -260,7 +260,7 @@ bool Control::isTouchInside(Touch* touch)
|
|||
{
|
||||
Point touchLocation = touch->getLocation(); // Get the touch position
|
||||
touchLocation = this->getParent()->convertToNodeSpace(touchLocation);
|
||||
Rect bBox=boundingBox();
|
||||
Rect bBox = getBoundingBox();
|
||||
return bBox.containsPoint(touchLocation);
|
||||
}
|
||||
|
||||
|
|
|
@ -568,7 +568,7 @@ void ControlButton::needsLayout()
|
|||
Size titleLabelSize;
|
||||
if (_titleLabel != NULL)
|
||||
{
|
||||
titleLabelSize = _titleLabel->boundingBox().size;
|
||||
titleLabelSize = _titleLabel->getBoundingBox().size;
|
||||
}
|
||||
|
||||
// Adjust the background image if necessary
|
||||
|
@ -603,12 +603,12 @@ void ControlButton::needsLayout()
|
|||
Rect rectTitle;
|
||||
if (_titleLabel != NULL)
|
||||
{
|
||||
rectTitle = _titleLabel->boundingBox();
|
||||
rectTitle = _titleLabel->getBoundingBox();
|
||||
}
|
||||
Rect rectBackground;
|
||||
if (_backgroundSprite != NULL)
|
||||
{
|
||||
rectBackground = _backgroundSprite->boundingBox();
|
||||
rectBackground = _backgroundSprite->getBoundingBox();
|
||||
}
|
||||
|
||||
Rect maxRect = ControlUtils::RectUnion(rectTitle, rectBackground);
|
||||
|
|
|
@ -67,7 +67,7 @@ bool ControlHuePicker::initWithTargetAndPos(Node* target, Point pos)
|
|||
this->setBackground(ControlUtils::addSpriteToTargetWithPosAndAnchor("huePickerBackground.png", target, pos, Point(0.0f, 0.0f)));
|
||||
this->setSlider(ControlUtils::addSpriteToTargetWithPosAndAnchor("colourPicker.png", target, pos, Point(0.5f, 0.5f)));
|
||||
|
||||
_slider->setPosition(Point(pos.x, pos.y + _background->boundingBox().size.height * 0.5f));
|
||||
_slider->setPosition(Point(pos.x, pos.y + _background->getBoundingBox().size.height * 0.5f));
|
||||
_startPos=pos;
|
||||
|
||||
// Sets the default value
|
||||
|
@ -96,7 +96,7 @@ void ControlHuePicker::setHuePercentage(float hueValueInPercent)
|
|||
_hue=_huePercentage*360.0f;
|
||||
|
||||
// Clamp the position of the icon within the circle
|
||||
Rect backgroundBox=_background->boundingBox();
|
||||
Rect backgroundBox=_background->getBoundingBox();
|
||||
|
||||
// Get the center point of the background image
|
||||
float centerX = _startPos.x + backgroundBox.size.width * 0.5f;
|
||||
|
@ -129,7 +129,7 @@ void ControlHuePicker::updateSliderPosition(Point location)
|
|||
{
|
||||
|
||||
// Clamp the position of the icon within the circle
|
||||
Rect backgroundBox=_background->boundingBox();
|
||||
Rect backgroundBox=_background->getBoundingBox();
|
||||
|
||||
// Get the center point of the background image
|
||||
float centerX = _startPos.x + backgroundBox.size.width * 0.5f;
|
||||
|
|
|
@ -121,8 +121,8 @@ void ControlSaturationBrightnessPicker::updateSliderPosition(Point sliderPositio
|
|||
// Clamp the position of the icon within the circle
|
||||
|
||||
// Get the center point of the bkgd image
|
||||
float centerX = _startPos.x + _background->boundingBox().size.width*0.5f;
|
||||
float centerY = _startPos.y + _background->boundingBox().size.height*0.5f;
|
||||
float centerX = _startPos.x + _background->getBoundingBox().size.width*0.5f;
|
||||
float centerY = _startPos.y + _background->getBoundingBox().size.height*0.5f;
|
||||
|
||||
// Work out the distance difference between the location and center
|
||||
float dx = sliderPosition.x - centerX;
|
||||
|
@ -133,7 +133,7 @@ void ControlSaturationBrightnessPicker::updateSliderPosition(Point sliderPositio
|
|||
float angle = atan2f(dy, dx);
|
||||
|
||||
// Set the limit to the slider movement within the colour picker
|
||||
float limit = _background->boundingBox().size.width*0.5f;
|
||||
float limit = _background->getBoundingBox().size.width*0.5f;
|
||||
|
||||
// Check distance doesn't exceed the bounds of the circle
|
||||
if (dist > limit)
|
||||
|
@ -162,8 +162,8 @@ bool ControlSaturationBrightnessPicker::checkSliderPosition(Point location)
|
|||
// Clamp the position of the icon within the circle
|
||||
|
||||
// get the center point of the bkgd image
|
||||
float centerX = _startPos.x + _background->boundingBox().size.width*0.5f;
|
||||
float centerY = _startPos.y + _background->boundingBox().size.height*0.5f;
|
||||
float centerX = _startPos.x + _background->getBoundingBox().size.width*0.5f;
|
||||
float centerY = _startPos.y + _background->getBoundingBox().size.height*0.5f;
|
||||
|
||||
// work out the distance difference between the location and center
|
||||
float dx = location.x - centerX;
|
||||
|
@ -171,7 +171,7 @@ bool ControlSaturationBrightnessPicker::checkSliderPosition(Point location)
|
|||
float dist = sqrtf(dx*dx+dy*dy);
|
||||
|
||||
// check that the touch location is within the bounding rectangle before sending updates
|
||||
if (dist <= _background->boundingBox().size.width*0.5f)
|
||||
if (dist <= _background->getBoundingBox().size.width*0.5f)
|
||||
{
|
||||
updateSliderPosition(location);
|
||||
sendActionsForControlEvents(ControlEventValueChanged);
|
||||
|
|
|
@ -91,7 +91,7 @@ ControlSlider* ControlSlider::create(Sprite * backgroundSprite, Sprite* pogressS
|
|||
this->setThumbSprite(thumbSprite);
|
||||
|
||||
// Defines the content size
|
||||
Rect maxRect = ControlUtils::RectUnion(backgroundSprite->boundingBox(), thumbSprite->boundingBox());
|
||||
Rect maxRect = ControlUtils::RectUnion(backgroundSprite->getBoundingBox(), thumbSprite->getBoundingBox());
|
||||
|
||||
setContentSize(Size(maxRect.size.width, maxRect.size.height));
|
||||
|
||||
|
@ -179,7 +179,7 @@ bool ControlSlider::isTouchInside(Touch * touch)
|
|||
Point touchLocation = touch->getLocation();
|
||||
touchLocation = this->getParent()->convertToNodeSpace(touchLocation);
|
||||
|
||||
Rect rect = this->boundingBox();
|
||||
Rect rect = this->getBoundingBox();
|
||||
rect.size.width += _thumbSprite->getContentSize().width;
|
||||
rect.origin.x -= _thumbSprite->getContentSize().width / 2;
|
||||
|
||||
|
|
|
@ -108,7 +108,7 @@ bool ControlStepper::initWithMinusSpriteAndPlusSprite(Sprite *minusSprite, Sprit
|
|||
_plusSprite->addChild(_plusLabel);
|
||||
|
||||
// Defines the content size
|
||||
Rect maxRect = ControlUtils::RectUnion(_minusSprite->boundingBox(), _plusSprite->boundingBox());
|
||||
Rect maxRect = ControlUtils::RectUnion(_minusSprite->getBoundingBox(), _plusSprite->getBoundingBox());
|
||||
this->setContentSize( Size(_minusSprite->getContentSize().width + _plusSprite->getContentSize().height, maxRect.size.height) );
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ bool ScrollView::isNodeVisible(Node* node)
|
|||
|
||||
viewRect = Rect(-offset.x/scale, -offset.y/scale, size.width/scale, size.height/scale);
|
||||
|
||||
return viewRect.intersectsRect(node->boundingBox());
|
||||
return viewRect.intersectsRect(node->getBoundingBox());
|
||||
}
|
||||
|
||||
void ScrollView::pause(Object* sender)
|
||||
|
|
|
@ -566,7 +566,7 @@ void TableView::ccTouchEnded(Touch *pTouch, Event *pEvent)
|
|||
}
|
||||
|
||||
if (_touchedCell){
|
||||
Rect bb = this->boundingBox();
|
||||
Rect bb = this->getBoundingBox();
|
||||
bb.origin = _parent->convertToWorldSpace(bb.origin);
|
||||
|
||||
if (bb.containsPoint(pTouch->getLocation()) && _tableViewDelegate != NULL)
|
||||
|
|
|
@ -148,7 +148,7 @@ PhysicsSprite* PhysicsSprite::create(const char *pszFileName, const Rect& rect)
|
|||
|
||||
// this method will only get called if the sprite is batched.
|
||||
// return YES if the physic's values (angles, position ) changed.
|
||||
// If you return NO, then nodeToParentTransform won't be called.
|
||||
// If you return NO, then getNodeToParentTransform won't be called.
|
||||
bool PhysicsSprite::isDirty() const
|
||||
{
|
||||
return true;
|
||||
|
@ -342,7 +342,7 @@ void PhysicsSprite::setRotation(float fRotation)
|
|||
}
|
||||
|
||||
// returns the transform matrix according the Chipmunk Body values
|
||||
AffineTransform PhysicsSprite::nodeToParentTransform()
|
||||
AffineTransform PhysicsSprite::getNodeToParentTransform() const
|
||||
{
|
||||
// Although scale is not used by physics engines, it is calculated just in case
|
||||
// the sprite is animated (scaled up/down) using actions.
|
||||
|
|
|
@ -96,15 +96,6 @@ public:
|
|||
bool isIgnoreBodyRotation() const;
|
||||
void setIgnoreBodyRotation(bool bIgnoreBodyRotation);
|
||||
|
||||
virtual const Point& getPosition() const;
|
||||
virtual void getPosition(float* x, float* y) const;
|
||||
virtual float getPositionX() const;
|
||||
virtual float getPositionY() const;
|
||||
virtual void setPosition(const Point &position);
|
||||
virtual float getRotation() const;
|
||||
virtual void setRotation(float fRotation);
|
||||
virtual AffineTransform nodeToParentTransform();
|
||||
|
||||
//
|
||||
// Chipmunk specific
|
||||
//
|
||||
|
@ -122,6 +113,16 @@ public:
|
|||
float getPTMRatio() const;
|
||||
void setPTMRatio(float fPTMRatio);
|
||||
|
||||
// overrides
|
||||
virtual const Point& getPosition() const override;
|
||||
virtual void getPosition(float* x, float* y) const override;
|
||||
virtual float getPositionX() const override;
|
||||
virtual float getPositionY() const override;
|
||||
virtual void setPosition(const Point &position) override;
|
||||
virtual float getRotation() const override;
|
||||
virtual void setRotation(float fRotation) override;
|
||||
virtual AffineTransform getNodeToParentTransform() const override;
|
||||
|
||||
protected:
|
||||
const Point& getPosFromPhysics() const;
|
||||
};
|
||||
|
|
|
@ -579,7 +579,7 @@ void TestBoundingBox::draw()
|
|||
{
|
||||
CC_NODE_DRAW_SETUP();
|
||||
|
||||
rect = RectApplyAffineTransform(armature->boundingBox(), armature->nodeToParentTransform());
|
||||
rect = RectApplyAffineTransform(armature->getBoundingBox(), armature->getNodeToParentTransform());
|
||||
|
||||
ccDrawColor4B(100, 100, 100, 255);
|
||||
ccDrawRect(rect.origin, Point(rect.getMaxX(), rect.getMaxY()));
|
||||
|
|
|
@ -1276,7 +1276,7 @@ void BitmapFontMultiLineAlignment::ccTouchesBegan(cocos2d::Set *pTouches, cocos2
|
|||
Touch *touch = (Touch *)pTouches->anyObject();
|
||||
Point location = touch->getLocationInView();
|
||||
|
||||
if (this->_arrowsShouldRetain->boundingBox().containsPoint(location))
|
||||
if (this->_arrowsShouldRetain->getBoundingBox().containsPoint(location))
|
||||
{
|
||||
_drag = true;
|
||||
this->_arrowsBarShouldRetain->setVisible(true);
|
||||
|
|
|
@ -39,7 +39,7 @@ void TextureAtlasEncryptionDemo::onEnter()
|
|||
this->addChild(nonencryptedSprite);
|
||||
|
||||
LabelTTF* nonencryptedSpriteLabel = LabelTTF::create("non-encrypted", "Arial", 28);
|
||||
nonencryptedSpriteLabel->setPosition(Point(s.width * 0.25f, nonencryptedSprite->boundingBox().getMinY() - nonencryptedSprite->getContentSize().height/2));
|
||||
nonencryptedSpriteLabel->setPosition(Point(s.width * 0.25f, nonencryptedSprite->getBoundingBox().getMinY() - nonencryptedSprite->getContentSize().height/2));
|
||||
this->addChild(nonencryptedSpriteLabel, 1);
|
||||
|
||||
// Load the encrypted atlas
|
||||
|
@ -66,7 +66,7 @@ void TextureAtlasEncryptionDemo::onEnter()
|
|||
this->addChild(encryptedSprite);
|
||||
|
||||
LabelTTF* encryptedSpriteLabel = LabelTTF::create("encrypted", "Arial", 28);
|
||||
encryptedSpriteLabel->setPosition(Point(s.width * 0.75f, encryptedSprite->boundingBox().getMinY() - encryptedSpriteLabel->getContentSize().height/2));
|
||||
encryptedSpriteLabel->setPosition(Point(s.width * 0.75f, encryptedSprite->getBoundingBox().getMinY() - encryptedSpriteLabel->getContentSize().height/2));
|
||||
this->addChild(encryptedSpriteLabel, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,4 +25,24 @@ var cc = cc || {};
|
|||
return cc.Animation.prototype.clone.apply(this, arguments);
|
||||
};
|
||||
|
||||
cc.Node.prototype.nodeToWorldTransform = function() {
|
||||
logW("cc.Node.nodeToWorldTransform", "cc.Node.getNodeToWorldTransform");
|
||||
return cc.Node.prototype.getNodeToWorldTransform.apply(this, arguments);
|
||||
};
|
||||
|
||||
cc.Node.prototype.nodeToParentTransform = function() {
|
||||
logW("cc.Node.nodeToParentTransform", "cc.Node.getNodeToParentTransform");
|
||||
return cc.Node.prototype.getNodeToParentTransform.apply(this, arguments);
|
||||
};
|
||||
|
||||
cc.Node.prototype.worldToNodeTransform = function() {
|
||||
logW("cc.Node.worldToNodeTransform", "cc.Node.getWorldToNodeTransform");
|
||||
return cc.Node.prototype.getWorldToNodeTransform.apply(this, arguments);
|
||||
};
|
||||
|
||||
cc.Node.prototype.parentToNodeTransform = function() {
|
||||
logW("cc.Node.parentToNodeTransform", "cc.Node.getParentToNodeTransform");
|
||||
return cc.Node.prototype.getParentToNodeTransform.apply(this, arguments);
|
||||
};
|
||||
|
||||
})();
|
||||
|
|
|
@ -113,7 +113,7 @@ rename_functions = SpriteFrameCache::[addSpriteFramesWithFile=addSpriteFrames sp
|
|||
LayerGradient::[initWithColor=init],
|
||||
LayerColor::[initWithColor=init],
|
||||
GLProgram::[fragmentShaderLog=getFragmentShaderLog initWithVertexShaderByteArray=initWithString initWithVertexShaderFilename=init programLog=getProgramLog setUniformLocationWith1i=setUniformLocationI32 vertexShaderLog=getVertexShaderLog],
|
||||
Node::[boundingBox=getBoundingBox removeFromParentAndCleanup=removeFromParent removeAllChildrenWithCleanup=removeAllChildren],
|
||||
Node::[removeFromParentAndCleanup=removeFromParent removeAllChildrenWithCleanup=removeAllChildren],
|
||||
LabelAtlas::[create=_create],
|
||||
TMXLayer::[tileAt=getTileAt tileGIDAt=getTileGIDAt propertyNamed=getProperty positionAt=getPositionAt],
|
||||
TileMapAtlas::[tileAt=getTileAt],
|
||||
|
|
Loading…
Reference in New Issue