mirror of https://github.com/axmolengine/axmol.git
add setGridTarget method, grid node now can affect its target and its child
This commit is contained in:
parent
09a9b1f557
commit
ea9d744d79
|
@ -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())
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue