如何在cocos2d中显示CCNode的定位点? [英] How can I display the anchorpoint for a CCNode in cocos2d?

查看:255
本文介绍了如何在cocos2d中显示CCNode的定位点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法显示CCNode的定位点?这将是非常有用的调试。

Is there a way to display a CCNode's anchor point? This would be very useful for debugging.

推荐答案

不内置,但您可以使用anchorPointInPoints属性在定位点位置绘制点或圆

-(void) draw
{
    [super draw];
    ccDrawCircle(self.anchorPointInPoints, 20, 0, 8, YES);
}

当然,我总是建议 anchorPoint在第一位。另一种方法是将节点添加到父节点,将其从父节点偏移,然后父节点的位置像子节点的锚点一样工作。其优点是,像boundingBox这样的方法不会偏离节点的位置(可能是命中检测的问题),您可以围绕其中心点和其父节点旋转子节点。

Of course, I always recommend not to change the anchorPoint in the first place. The alternative is to add the node to a parent node, offset it from the parent, and then the parent's position acts like the anchorpoint for the child node. The advantage is that methods like boundingBox aren't offset from the node's position (can be an issue for hit detection), and you can rotate the child node around its center point and around its parent.

这篇关于如何在cocos2d中显示CCNode的定位点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆