Cocos2d:动态更改精灵的 zOrder(使用 CCSpriteBatchNode)
有没有办法改变CCSpriteBatchNode渲染的精灵的zOrder?我尝试过这样的操作:
[self reorderChild:mySprite z:indexOfAnArray];
我收到此错误:'如果 CCSprite 正在由 CCSpriteBatchNode 渲染,则不应调用 CCSprite#draw'
我还尝试了精灵的 zOrder 属性,但不幸的是只读。 我需要更改 zOrder,因为根据精灵出现的位置,需要更改 zOrder。
Is there a way to change the zOrder of a sprite rendered by CCSpriteBatchNode? I've tried it like this:
[self reorderChild:mySprite z:indexOfAnArray];
I get this error: 'If CCSprite is being rendered by CCSpriteBatchNode, CCSprite#draw SHOULD NOT be called'
I also tried with the zOrder property of the sprite but unfortunately is read-only.
I need to change the zOrder because, depending on the position where my sprite will appear, the zOrder needs to be changed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
self
可能不是sprite
的父级。请记住,父级是保存它的CCSpriteBatchNode
,而从您的角度来看,self
可能是场景。self
is probably not the parent ofsprite
. Remember that the parent is theCCSpriteBatchNode
that holds it, andself
is, from your point of view, probably the scene.