Node之锚点

来源:互联网 发布:画线路图用什么软件 编辑:程序博客网 时间:2024/05/20 05:55

local function Test2()
local layer = getBaseLayer()

local sp1 = cc.Sprite:create(s_pPathSister1)local sp2 = cc.Sprite:create(s_pPathSister2)local sp3 = cc.Sprite:create(s_pPathSister1)local sp4 = cc.Sprite:create(s_pPathSister2)sp1:setPosition(cc.p(100, s.height /2))sp2:setPosition(cc.p(380, s.height /2))layer:addChild(sp1)layer:addChild(sp2)sp3:setScale(0.25)sp4:setScale(0.25)sp1:addChild(sp3) //子节点是跟父节点一起执行动作sp2:addChild(sp4)local a1 = cc.RotateBy:create(2, 360)local a2 = cc.ScaleBy:create(2, 2)local action1 = cc.RepeatForever:create(cc.Sequence:create(a1, a2, a2:reverse()))local action2 = cc.RepeatForever:create(cc.Sequence:create(a1:clone(), a2:clone(), a2:reverse()))//因为action1跟action2是同时执行的,所以action2的动作序列的创建需要将a1、a2克隆出来sp2:setAnchorPoint(cc.p(1.0,1.0))//sp1:setAnchorPoint(cc.p(0,0))  sp1的锚点有个默认ccp(0.5,0.5)sp1:runAction(action1)  sp2:runAction(action2)Helper.titleLabel:setString("anchorPoint and children")return layer

end

0 0
原创粉丝点击