我使用了,cocostudio,帧动画,请问,如何判定帧动画执行完毕?
求大神了
可以在cocostudio里的最后一帧上加个帧事件,程序里监听到这个帧事件就知道是执行完了
local c
local a
local b
a = math.pow(t.y1 - t.y2,2)
b = math.pow(t.x1 - t.x2,2)
c = math.pow(a+b, 1/2)
actions:setScaleX(c/size.width)
actions:setRotation(jiaodu)
Layer:addChild(actions)
–Layer:removeChild(actions)
这里removeChild执行的 话,动画也不执行了
怎么做啊?
你用cocostudio不知道它里面的帧事件?
我是用LUA做的,新手哦。。。大神多多包涵~~~
animation:setFrameEventCallFunc(function(bone,event,originFrameIndex,intcurrentFrameIndex)
if event == “fire” then
print(“开火…”)
elseif event == “over” then
print(“结束…”)
end
end
谢谢大神,我明白了。。。。
好人有好报,祝你事业顺利,阖家平安
armature是有播放事件的哦~~
setMovementEventCallFunc
返回类型有
enum MovementEventType
{
START,
COMPLETE,
LOOP_COMPLETE
};
actions = CCArmature:create(“ShanDian”)
actions:getAnimation():playWithIndex(0)
actions:setScaleX(1)
actions:setScaleY(1)
………………
Layer:addChild(actions)
– 这里回调
actions:getAnimation():setMovementEventCallFunc(animationEvent)
–这里回调函数
local function animationEvent(armatureBack,movementType,movementID)
print(armatureBack)
print(movementType)
print(movementID)
if movementType == 1 then
print (“aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”)
if (movementID == “over”) then
Layer:removeChild(actions)
end
end
end
–下面是打印结果
userdata
2
Animation1
userdata
2
Animation1
userdata
2
Animation1
userdata
2
Animation1
userdata
2
Animation1
userdata
2
Animation1
……………………
请问一下大神,这要怎么解决?
学习了
用setFrameEventCallFunc
local function animationEvent(armatureBack,movementType,movementID)
if movementID == 22 then
Layer:removeChild(actions)
end
end
搞定了。。。。cocostudio,第22帧结束
就用这个:
–回调函数
local function animationEvent(armatureBack,movementType,movementID) }]V A1N
if movementID == 22 then AO)#Dg!
Layer:removeChild(actions) isnSkfQU
end p~w9U fY
end
–下面是回调
actions:getAnimation():setFrameEventCallFunc(animationEvent)
搞定了。。。。cocostudio,第22帧结束
就用这个:
–回调函数
local function animationEvent(armatureBack,movementType,movementID)
if movementID == 22 then
Layer:removeChild(actions)
end
end
–下面是回调
actions:getAnimation():setFrameEventCallFunc(animationEvent)