转载出处:http://blog.youkuaiyun.com/mofiu/article/details/78751138
代码如下:
--layout
local laytest = ccui.Layout:create()
laytest:setContentSize(cc.size(300,300))
laytest:setPosition(cc.p(200, 300))
laytest:setAnchorPoint(cc.p(0, 0))
layer:addChild(laytest)
-- callback
local function menuItemHelpCallback1(sender)
local HAND_CARD_COUNT=13
for i=1,13 do
local card = cardlist[i]
card:stopAllActions()
card:setVisible(true)
card:setPosition(laytest:getContentSize().width/2, laytest:getContentSize().height)
card:setRotation(0)
card:runAction(transition.sequence({
cc.DelayTime:create(i * 0.),
cc.MoveTo:create(0.5,cc.p(45+18*(i-1),laytest:getContentSize().height/2)),
}))
end
end
可以根据上面代码修改为很多种动画,例如:
代码
--layout
local laytest = ccui.Layout:create()
laytest:setContentSize(cc.size(300,300))
laytest:setPosition(cc.p(200, 300))
laytest:setAnchorPoint(cc.p(0, 0))
layer:addChild(laytest)
-- callback
local function menuItemHelpCallback1(sender)
local HAND_CARD_COUNT=13
for i=1,13 do
local card = cardlist[i]
card:stopAllActions()
card:setVisible(true)
card:setPosition(laytest:getContentSize().width/2, laytest:getContentSize().height)
card:setRotation(0)
card:runAction(transition.sequence({
cc.DelayTime:create(i * 0.),
cc.MoveTo:create(0.5,cc.p(45+18*(i-1),laytest:getContentSize().height/2)),
}))
end
end
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
local function setcardimg(card,img)
--local t = cc.TextureCache:getInstance():addImage(img)
local t=cc.Director:getInstance():getTextureCache():addImage(img)
card:setTexture(t)
end
local function menuItemHelpCallback1(sender)
local HAND_CARD_COUNT=13
for i=1,13 do
local card = cardlist[i]
setcardimg(card,"card_b.png")
card:stopAllActions()
card:setVisible(true)
card:setPosition(laytest:getContentSize().width/2, laytest:getContentSize().height)
card:setRotation(0)
local xy = cc.p(45+30*(i-1),laytest:getContentSize().height/2)
card:runAction(transition.sequence({
cc.DelayTime:create(i * 0.05),
cc.MoveTo:create(0.2,xy),
cc.CallFunc:create(function()
setcardimg(card,"card4.png")
end),
}))
end
end
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24