|
-
- local MJDefine=MJFramework.MJImport("mj.luaScript.MJDefine")
- local MJ=MJFramework.MJImport("mj.luaScript.Views.Game.MJ")
-
- local zigongAnimationCompnent = MJFramework.MJFrameworkClassImprot("mj.luaScript.Views.Compnent.MJAnimationCompnent")
- function zigongAnimationCompnent.CreateOperareEffect(opType,callback)
- if zigongAnimationCompnent.effect[opType] then
- -- local bg = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_text_bg.png")
-
- local sprite=cc.Sprite:create(zigongAnimationCompnent.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 zigongAnimationCompnent.CreateHuEffect(huType,callback)
- local sprite
- if huType == MJDefine.MJGameHuType.HU_ZIMO then
- sprite=cc.Sprite:create(zigongAnimationCompnent.effect[MJDefine.MJOperateType.OPREATE_ZIMOHU])
- elseif huType == MJDefine.MJGameHuType.HU_QIANGGANG then
- sprite=cc.Sprite:create(zigongAnimationCompnent.effect[MJDefine.MJOperateType.OPREATE_QIANG_GANG_HU])
- else
- sprite=cc.Sprite:create(zigongAnimationCompnent.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 zigongAnimationCompnent.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(zigongAnimationCompnent.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 zigongAnimationCompnent.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 zigongAnimationCompnent.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 zigongAnimationCompnent.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 zigongAnimationCompnent.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 zigongAnimationCompnent.CreateLoBoEffect(card,desktopType,callback)
- if desktopType == MJDefine.DesktopType.ThreeD then
- desktopType = MJDefine.DesktopType.TwoD
- end
- local mj=MJ:new(0,MJDefine.MJType.Out,MJDefine.MyViewId,desktopType)
- mj:setScale(1.5)
- local action = {
- cc.MoveBy:create(0.3,cc.p(0,25)),
- cc.CallFunc:create(function()
- local lightEffect = zigongAnimationCompnent.createLuoBoLightEffect()
- local mjSize = mj:getContentSize()
- lightEffect:setPosition(cc.p(mjSize.width/2,mjSize.height/2+5))
- mj:addChild(lightEffect)
-
- local newValue=string.format("%x",card)
- mj:setOutImage(newValue,MJDefine.MyViewId)
- local sprite = cc.Sprite:createWithSpriteFrameName("zg_room_luoboyezi.png")
- sprite:setScale(0.6)
- sprite:setPosition(cc.p(mjSize.width/2-2,mjSize.height+8))
- mj:addChild(sprite,-1)
- end),
- cc.DelayTime:create(0.3),--光效时间
- --cc.DelayTime:create(3.0),--停留时间(播完光效停留几秒进入小局)
- cc.CallFunc:create(function()
- if callback then
- callback()
- end
- end),
- --cc.RemoveSelf:create(),
- }
- mj:runAction(cc.Sequence:create(action))
- return mj
- end
-
- --萝卜光效
- function zigongAnimationCompnent.createLuoBoLightEffect()
- -- 加载第一张图片
- local nodeImage = cc.ImageView:createNode()
- nodeImage:loadTexture(string.format("luobo-texiao_%d",0))
- -- 循环修改图片
- local everyFrame = 0.025
- local indexFace = 0
- local indexMax = 14
- 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("luobo-texiao_%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 zigongAnimationCompnent.CreateLoBoLabel(num,callback)
- local sprite = cc.Sprite:createWithSpriteFrameName("zg_room_luobo.png")
-
- local txtX = cc.TextBMFont:createNode()
- txtX:setFntFile("res/fonts/luobonum.fnt")
- txtX:setString("*")
- txtX:setLocalZOrder(1001)
- sprite:addChild(txtX)
-
- local txt = cc.TextBMFont:createNode()
- txt:setFntFile("res/fonts/luobonum.fnt")
- txt:setString(string.format("%d", num))
- --txt:setTag(166)
- txt:setLocalZOrder(1001)
- sprite:addChild(txt)
-
- local size= sprite:getContentSize()
- txtX:setPosition(cc.p(size.width+22,size.height/2-5))
- txt:setPosition(cc.p(size.width+55,size.height/2+5))
- local action = {
- cc.DelayTime:create(1.5),
- cc.CallFunc:create(function()
- if callback then
- callback()
- end
- end),
- }
- sprite:runAction(cc.Sequence:create(action))
- return sprite
- end
-
- -- 飘
- function zigongAnimationCompnent.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 zigongAnimationCompnent.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 zigongAnimationCompnent.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 zigongAnimationCompnent
|