一个单独的A类,继承自Sprite类,因为某些原因需要重新setTexture,并且是SpriteBatchNode的对象,本以为是个小改,没想到重新运行后什么图像都没了……
重新找了一下原因,发现Sprite的createWithTexture方法中,在initWithTexture方法最后里面不仅setTexture,还setTextureRect。HOHO,原来是这个原因,所以光针对Sprite去setTexture还不够,还需要在后面补充一个setTextureRect才可以。
SpriteBatchNode* BatchNode = SpriteBatchNode::create("a.png",10000); for (Index; Index < 10000; Index++) { A* pA = A::create();
<span style="white-space: pre;"> </span>pA->setTexture(BatchNode->getTexture()); Rect _rect = Rect::ZERO; _rect.size = BatchNode->getTexture()->getContentSize(); pA->setTextureRect(_rect); pA->setPosition(100,i);
<span style="white-space:pre"> </span>this->addChild(pA); }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。