local MJDefine=MJFramework.MJImport("mj.luaScript.MJDefine") local MJ=MJFramework.MJImport("mj.luaScript.Views.Game.MJ") local xueliuAnimationCompnent = MJFramework.MJFrameworkClassImprot("mj.luaScript.Views.Compnent.MJAnimationCompnent") function xueliuAnimationCompnent.CreateOperareEffect(opType,callback) if xueliuAnimationCompnent.effect[opType] then -- local bg = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_text_bg.png") local sprite=cc.Sprite:create(xueliuAnimationCompnent.effect[opType]) sprite:setOpacity(150) sprite:setScale(0.5) -- sprite:addChild(bg,-1) -- local size= sprite:getContentSize() -- bg:setPosition(cc.p(size.width/2,size.height/2)) local action={ cc.Spawn:create(cc.EaseBackOut:create(cc.ScaleTo:create(0.2,1)),cc.FadeTo:create(0.2,255)), cc.DelayTime:create(0.1), cc.Spawn:create(cc.EaseBackIn:create(cc.ScaleTo:create(0.2,0)),cc.FadeTo:create(0.2,100)), cc.CallFunc:create(function() if callback then callback() end end), cc.RemoveSelf:create(), } sprite:runAction(cc.Sequence:create(action)) return sprite end end function xueliuAnimationCompnent.CreateHuEffect(huType,callback) local sprite if huType == MJDefine.MJGameHuType.HU_ZIMO then sprite=cc.Sprite:create(xueliuAnimationCompnent.effect[MJDefine.MJOperateType.OPREATE_ZIMOHU]) elseif huType == MJDefine.MJGameHuType.HU_QIANGGANG then sprite=cc.Sprite:create(xueliuAnimationCompnent.effect[MJDefine.MJOperateType.OPREATE_QIANG_GANG_HU]) else sprite=cc.Sprite:create(xueliuAnimationCompnent.effect[MJDefine.MJOperateType.OPREATE_DIANPAOHU]) end -- local bg = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_text_bg.png") -- sprite:addChild(bg,-1) -- local size= sprite:getContentSize() -- bg:setPosition(cc.p(size.width/2,size.height/2)) sprite:setOpacity(150) sprite:setScale(0.5) local action={ cc.Spawn:create(cc.EaseBackOut:create(cc.ScaleTo:create(0.2,1)),cc.FadeTo:create(0.2,255)), cc.DelayTime:create(0.2), cc.Spawn:create(cc.EaseBackIn:create(cc.ScaleTo:create(0.2,0)),cc.FadeTo:create(0.2,100)), cc.RemoveSelf:create(), cc.CallFunc:create(function() if callback then callback() end end), } sprite:runAction(cc.Sequence:create(action)) return sprite end function xueliuAnimationCompnent.CreateHuOrderEffect(huType,order,callback) local orderNum = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_num"..order..".png") local sprite = nil if huType == MJDefine.MJGameHuType.HU_ZIMO then sprite=cc.Sprite:create(xueliuAnimationCompnent.effect[MJDefine.MJOperateType.OPREATE_ZIMOHU]) orderNum:setPosition(cc.p(260,65)) else sprite=cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_jiepao.png") orderNum:setPosition(cc.p(300,65)) end sprite:addChild(orderNum) local bg = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_text_bg.png") sprite:addChild(bg,-1) local size= sprite:getContentSize() bg:setPosition(cc.p(size.width/2,size.height/2)) sprite:setScale(0.5) local action={ cc.DelayTime:create(0.2), cc.CallFunc:create(function() if callback then callback() end end), } sprite:runAction(cc.Sequence:create(action)) return sprite end -- 爆牌 function xueliuAnimationCompnent.CreateBaoEffect(callback) local sprite = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_baojiao.png") -- sprite:loadTexture("luzhou_effect_img_bao.png", 1) sprite:setOpacity(150) sprite:setScale(0.5) local bg = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_text_bg.png") sprite:addChild(bg,-1) local size= sprite:getContentSize() bg:setPosition(cc.p(size.width/2,size.height/2)) local action = { cc.Spawn:create(cc.EaseBackOut:create(cc.ScaleTo:create(0.2,1)),cc.FadeTo:create(0.2,255)), cc.DelayTime:create(0.2), cc.Spawn:create(cc.EaseBackIn:create(cc.ScaleTo:create(0.2,0)),cc.FadeTo:create(0.2,100)), cc.CallFunc:create(function() if callback then callback() end end), cc.RemoveSelf:create(), } sprite:runAction(cc.Sequence:create(action)) return sprite end -- 放炮 function xueliuAnimationCompnent.CreateDianPaoEffect(callback) local sprite = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_fangpao.png") -- sprite:loadTexture("luzhou_effect_img_bao.png", 1) sprite:setOpacity(150) sprite:setScale(0.5) local action = { cc.Spawn:create(cc.EaseBackOut:create(cc.ScaleTo:create(0.2,1)),cc.FadeTo:create(0.2,255)), cc.DelayTime:create(0.2), cc.Spawn:create(cc.EaseBackIn:create(cc.ScaleTo:create(0.2,0)),cc.FadeTo:create(0.2,100)), cc.CallFunc:create(function() if callback then callback() end end), cc.RemoveSelf:create(), } sprite:runAction(cc.Sequence:create(action)) return sprite end function xueliuAnimationCompnent.CreateStartSendCards(handViews,callback) local index=0 local t=0.05 local height=60 local PCount = table.nums(handViews) for k,v in pairs(handViews) do for _,mj in pairs(v.handCards) do mj:setOpacity(0)--setVisible(false) end local startIndex=1 local function nextAction() for i=startIndex,startIndex+3 do if v.handCards[i] then -- v.handCards[i]:setVisible(true) v.handCards[i]:setPositionY(v.handCards[i]:getPositionY()+height) v.handCards[i]:runAction(cc.EaseIn:create(cc.MoveBy:create(t,cc.p(0,-height)),t)) v.handCards[i]:runAction(cc.FadeTo:create(t, 255)) -- v.handCards[i]:runAction(cc.Sequence:create(cc.MoveBy:create(0.3,cc.p(0,-50)),cc.CallFunc(function() -- v.handCards[i]:setVisible(true) -- end))) end --[[if i==#v.handCards then v:stopAllActions() end--]] end startIndex=startIndex+4 end local actions={ cc.DelayTime:create(t*index), cc.CallFunc:create(nextAction), cc.DelayTime:create(t*PCount), cc.CallFunc:create(nextAction), cc.DelayTime:create(t*PCount), cc.CallFunc:create(nextAction), cc.DelayTime:create(t*PCount), cc.CallFunc:create(nextAction), } if index==table.nums(handViews)-1 then table.insert(actions,cc.DelayTime:create(0.3)) table.insert(actions,cc.CallFunc:create(function() if callback then callback() end end)) end v:runAction(cc.Sequence:create(actions)) index=index+1 end end -- 博自摸 function xueliuAnimationCompnent.CreateBoZiMoEffect(callback) local sprite = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_bozimo.png") sprite:setOpacity(150) sprite:setScale(0.5) local bg = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_text_bg.png") sprite:addChild(bg,-1) local size= sprite:getContentSize() bg:setPosition(cc.p(size.width/2,size.height/2)) local action = { cc.Spawn:create(cc.EaseBackOut:create(cc.ScaleTo:create(0.2,1)),cc.FadeTo:create(0.2,255)), cc.DelayTime:create(0.1), cc.Spawn:create(cc.EaseBackIn:create(cc.ScaleTo:create(0.2,0)),cc.FadeTo:create(0.2,100)), cc.CallFunc:create(function() if callback then callback() end end), cc.RemoveSelf:create(), } sprite:runAction(cc.Sequence:create(action)) return sprite end -- 飘 function xueliuAnimationCompnent.CreatePiaoEffect(callback, isRemoveSelf) isRemoveSelf = false local sprite = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_piao.png") sprite:setOpacity(150) sprite:setScale(isRemoveSelf and 0.5 or 0.3) local action={ cc.Spawn:create(cc.EaseBackOut:create(cc.ScaleTo:create(0.3,isRemoveSelf and 1.0 or 0.5)),cc.FadeTo:create(0.3,255)), cc.DelayTime:create(0.1), cc.Spawn:create(cc.EaseBackIn:create(cc.ScaleTo:create(0.2, isRemoveSelf and 0 or 0.5)),cc.FadeTo:create(0.2, isRemoveSelf and 100 or 255)), cc.CallFunc:create(function() if callback then callback() end end), isRemoveSelf and cc.RemoveSelf:create() } sprite:runAction(cc.Sequence:create(action)) return sprite end --刮风光效 function xueliuAnimationCompnent.createGuaFengEffect() -- 加载第一张图片 local nodeImage = cc.ImageView:createNode() nodeImage:loadTexture(string.format("guafeng_%d",0)) -- 循环修改图片 local everyFrame = 0.035 local indexFace = 0 local indexMax = 18 local action1 = cc.Sequence:create(cc.DelayTime:create(everyFrame),cc.CallFunc:create(function () indexFace = indexFace + 1 if 0 < indexFace and indexFace < indexMax then else nodeImage:removeFromParent() return end local name = string.format("guafeng_%d.png",indexFace) if not tolua.isnull(nodeImage) then nodeImage:loadTexture(name, cc.TextureResType.plistType) end end)) local action2 = cc.Repeat:create(action1, indexMax+1) --nodeImage:stopAllActions() --nodeImage:runAction(cc.RepeatForever:create(action2)); nodeImage:runAction(action2) nodeImage:setVisible(true) return nodeImage end --下雨光效 function xueliuAnimationCompnent.createXiaYuEffect() -- 加载第一张图片 local nodeImage = cc.ImageView:createNode() nodeImage:loadTexture(string.format("xiayu-animation_%d",0)) -- 循环修改图片 local everyFrame = 0.035 local indexFace = 0 local indexMax = 16 local action1 = cc.Sequence:create(cc.DelayTime:create(everyFrame),cc.CallFunc:create(function () indexFace = indexFace + 1 if 0 < indexFace and indexFace < indexMax then else nodeImage:removeFromParent() return end local name = string.format("xiayu-animation_%d.png",indexFace) if not tolua.isnull(nodeImage) then nodeImage:loadTexture(name, cc.TextureResType.plistType) end end)) local action2 = cc.Repeat:create(action1, indexMax+1) --nodeImage:stopAllActions() --nodeImage:runAction(cc.RepeatForever:create(action2)); nodeImage:runAction(action2) nodeImage:setVisible(true) return nodeImage end return xueliuAnimationCompnent