关于cocos2dx的AnchorPoint

来源:互联网 发布:sql2000数据库置疑 编辑:程序博客网 时间:2024/06/05 11:21

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,它们的锚点不会被忽略。
0 0