您的位置:首页 > Web前端 > Node.js

Node之锚点

2015-10-20 21:46 459 查看
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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Node-锚点