add setGridTarget method, grid node now can affect its target and its child

This commit is contained in:
Huabing.Xu 2013-12-12 13:21:14 +08:00
parent 09a9b1f557
commit ea9d744d79
2 changed files with 18 additions and 0 deletions

View File

@ -23,13 +23,22 @@ GridNode* GridNode::create()
GridNode::GridNode()
:Node()
,_nodeGrid(nullptr)
,_gridTarget(nullptr)
{
}
void GridNode::setGridTarget(Node* target)
{
CC_SAFE_RELEASE(_gridTarget);
CC_SAFE_RETAIN(target);
_gridTarget = target;
}
GridNode::~GridNode()
{
CC_SAFE_RELEASE(_nodeGrid);
CC_SAFE_RELEASE(_gridTarget);
}
bool GridNode::init()
@ -53,6 +62,12 @@ void GridNode::visit()
}
this->transform();
if(_gridTarget)
{
_gridTarget->visit();
}
int i = 0;
if(!_children.empty())

View File

@ -27,11 +27,14 @@ public:
virtual bool init();
virtual void visit();
void setGridTarget(Node *target);
protected:
GridNode();
virtual ~GridNode();
protected:
Node* _gridTarget;
GridBase* _nodeGrid;
};
NS_CC_END