diff --git a/cocos/2d/CCLabelBMFont.cpp b/cocos/2d/CCLabelBMFont.cpp index 7dfe8b846c..e81d57a2dc 100644 --- a/cocos/2d/CCLabelBMFont.cpp +++ b/cocos/2d/CCLabelBMFont.cpp @@ -181,7 +181,7 @@ const BlendFunc &LabelBMFont::getBlendFunc() const return _label->getBlendFunc(); } -Node* LabelBMFont::getChildByTag(int tag) +Node* LabelBMFont::getChildByTag(int tag) const { return _label->getLetter(tag); } diff --git a/cocos/2d/CCLabelBMFont.h b/cocos/2d/CCLabelBMFont.h index 5479adf0a3..595ce7cbb2 100644 --- a/cocos/2d/CCLabelBMFont.h +++ b/cocos/2d/CCLabelBMFont.h @@ -115,7 +115,7 @@ public: virtual const BlendFunc &getBlendFunc() const override; virtual Sprite * getLetter(int ID); - virtual Node * getChildByTag(int tag) override; + virtual Node * getChildByTag(int tag) const override; virtual void setColor(const Color3B& color) override; diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index d7451357ac..3fa0df21c5 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -718,7 +718,7 @@ void Node::childrenAlloc(void) _children.reserve(4); } -Node* Node::getChildByTag(int tag) +Node* Node::getChildByTag(int tag) const { CCASSERT( tag != Node::INVALID_TAG, "Invalid tag"); diff --git a/cocos/2d/CCNode.h b/cocos/2d/CCNode.h index e08fa3d779..d29a589728 100644 --- a/cocos/2d/CCNode.h +++ b/cocos/2d/CCNode.h @@ -643,7 +643,7 @@ public: * * @return a Node object whose tag equals to the input parameter */ - virtual Node * getChildByTag(int tag); + virtual Node * getChildByTag(int tag) const; /** * Returns the array of the node's children * diff --git a/cocos/ui/UIListView.h b/cocos/ui/UIListView.h index 5407dd4b41..f3cbe11e8b 100644 --- a/cocos/ui/UIListView.h +++ b/cocos/ui/UIListView.h @@ -196,7 +196,7 @@ protected: virtual Vector& getChildren() override{return ScrollView::getChildren();}; virtual const Vector& getChildren() const override{return ScrollView::getChildren();}; virtual ssize_t getChildrenCount() const override {return ScrollView::getChildrenCount();}; - virtual Node * getChildByTag(int tag) override {return ScrollView::getChildByTag(tag);}; + virtual Node * getChildByTag(int tag) const override {return ScrollView::getChildByTag(tag);}; virtual Widget* getChildByName(const std::string& name) override {return ScrollView::getChildByName(name);}; void updateInnerContainerSize(); void remedyLayoutParameter(Widget* item); diff --git a/cocos/ui/UIPageView.h b/cocos/ui/UIPageView.h index 75153408a4..ff180ded2f 100644 --- a/cocos/ui/UIPageView.h +++ b/cocos/ui/UIPageView.h @@ -183,7 +183,7 @@ protected: virtual Vector& getChildren() override{return Widget::getChildren();}; virtual const Vector& getChildren() const override{return Widget::getChildren();}; virtual ssize_t getChildrenCount() const override {return Widget::getChildrenCount();}; - virtual Node * getChildByTag(int tag) override {return Widget::getChildByTag(tag);}; + virtual Node * getChildByTag(int tag) const override {return Widget::getChildByTag(tag);}; virtual Widget* getChildByName(const std::string& name) override {return Widget::getChildByName(name);}; Layout* createPage(); diff --git a/cocos/ui/UIScrollView.cpp b/cocos/ui/UIScrollView.cpp index 646f743bee..09d0275ab8 100644 --- a/cocos/ui/UIScrollView.cpp +++ b/cocos/ui/UIScrollView.cpp @@ -301,7 +301,7 @@ ssize_t ScrollView::getChildrenCount() const return _innerContainer->getChildrenCount(); } -Node* ScrollView::getChildByTag(int tag) +Node* ScrollView::getChildByTag(int tag) const { return _innerContainer->getChildByTag(tag); } diff --git a/cocos/ui/UIScrollView.h b/cocos/ui/UIScrollView.h index 2f986dfdeb..754e006290 100644 --- a/cocos/ui/UIScrollView.h +++ b/cocos/ui/UIScrollView.h @@ -296,7 +296,7 @@ public: virtual ssize_t getChildrenCount() const override; - virtual Node * getChildByTag(int tag) override; + virtual Node * getChildByTag(int tag) const override; virtual Widget* getChildByName(const std::string& name) override;