Cocos2dX 动作结束回调应用

前端之家收集整理的这篇文章主要介绍了Cocos2dX 动作结束回调应用前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

版本3.3 项目类型Lua

-- 活动NPC面板点击事件处理
function Home_NPCPanelClick(sender,eventType)
    if eventType == ccui.TouchEventType.ended then
        AudioManager:playButtonEffect()
        local cnt = table.getn(Home.tabNPCActivityBtn)
        Home.PanelNpc:setTouchEnabled(false)
        if Home.superStar then
            for i = 1,cnt do
                for i = 1,cnt do
                    Home.tabNPCActivityBtn[i]:setTouchEnabled(false)
                end
                local actionFadout = cc.FadeOut:create(0.5)
                local moveTo = cc.MoveTo:create(0.5,cc.p(175,175))
                local function actionCallFunc(sender)
                    if i == cnt then
                        Home.PanelNpc:setTouchEnabled(true)
                    end
                end
                
                Home.tabNPCActivityBtn[i]:runAction(cc.Sequence:create(moveTo,actionFadout,cc.CallFunc:create(actionCallFunc)))
                Home.tabNPCActivityBtn[i]:runAction(actionFadout)
            end
            Home.superStar = not(Home.superStar)
        else
            Home.PanelNpc:setTouchEnabled(false)
            for i = 1,cnt do
                local actionFadeIn = cc.FadeIn:create(0.5)
                local moveTo = cc.MoveTo:create(0.5,Home.tabNPCBtnActivityBtnPos[i])

                local function actionCallFunc(sender)
                    sender:setTouchEnabled(true)
                    if i == cnt then
                        Home.PanelNpc:setTouchEnabled(true)
                    end
                end

                Home.tabNPCActivityBtn[i]:runAction(cc.Sequence:create(moveTo,actionFadeIn,cc.CallFunc:create(actionCallFunc))           
            end
            Home.superStar = not(Home.superStar)
        end
        
    end
end

猜你在找的Cocos2d-x相关文章