关于cocos2dx的AnchorPoint

http://blog.163.com/jtyp_2000/blog/static/9910426201310902752875/


CCPoint AnchorPoint:AnchorPoint 用于设置一个锚点,以便精确地控制节点的位置和变换。


AnchorPoint 的两个参量x 和y 的取值通常都是0 到1 之间的实数,表示锚点相对于节点长宽的位置。
例如,把节点左下角作为锚点,值为(0,0) ;
把节点的中心作为锚点,值为(0.5,0.5) ;
把节点右下角作为锚点,值为(1,0) 。

 /**
     * Sets the anchor point in percent.
     *
     * anchorPoint is the point around which all transformations and positioning manipulations take place.
     * It's like a pin in the node where it is "attached" to its parent.
     * The anchorPoint is normalized, like a percentage. (0,0) means the bottom-left corner and (1,1) means the top-right corner.
     * But you can use values higher than (1,1) and lower than (0,0) too.
     * The default anchorPoint is (0.5,0.5), so it starts in the center of the node.
     *
     * @param anchorPoint   The anchor point of node.
     */
AnchorPoint默认值为(0.5,0.5) . 

Position用于设置节点的位置。由于 Position指的是锚点在父节点中的坐标值,节点显示的位置通常与锚点有关。


对于场景或层等大型节点,它们的IgnoreAnchorPointForPosition属性为 true ,此时引擎会认为 AnchorPoint 永远为(0,0);
而其他节点的该属性为flase,它们的锚点不会被忽略。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值