You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

301 line
9.5 KiB

  1. local MJDefine=MJFramework.MJImport("mj.luaScript.MJDefine")
  2. local MJ=MJFramework.MJImport("mj.luaScript.Views.Game.MJ")
  3. local xueliuAnimationCompnent = MJFramework.MJFrameworkClassImprot("mj.luaScript.Views.Compnent.MJAnimationCompnent")
  4. function xueliuAnimationCompnent.CreateOperareEffect(opType,callback)
  5. if xueliuAnimationCompnent.effect[opType] then
  6. -- local bg = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_text_bg.png")
  7. local sprite=cc.Sprite:create(xueliuAnimationCompnent.effect[opType])
  8. sprite:setOpacity(150)
  9. sprite:setScale(0.5)
  10. -- sprite:addChild(bg,-1)
  11. -- local size= sprite:getContentSize()
  12. -- bg:setPosition(cc.p(size.width/2,size.height/2))
  13. local action={
  14. cc.Spawn:create(cc.EaseBackOut:create(cc.ScaleTo:create(0.2,1)),cc.FadeTo:create(0.2,255)),
  15. cc.DelayTime:create(0.1),
  16. cc.Spawn:create(cc.EaseBackIn:create(cc.ScaleTo:create(0.2,0)),cc.FadeTo:create(0.2,100)),
  17. cc.CallFunc:create(function()
  18. if callback then
  19. callback()
  20. end
  21. end),
  22. cc.RemoveSelf:create(),
  23. }
  24. sprite:runAction(cc.Sequence:create(action))
  25. return sprite
  26. end
  27. end
  28. function xueliuAnimationCompnent.CreateHuEffect(huType,callback)
  29. local sprite
  30. if huType == MJDefine.MJGameHuType.HU_ZIMO then
  31. sprite=cc.Sprite:create(xueliuAnimationCompnent.effect[MJDefine.MJOperateType.OPREATE_ZIMOHU])
  32. elseif huType == MJDefine.MJGameHuType.HU_QIANGGANG then
  33. sprite=cc.Sprite:create(xueliuAnimationCompnent.effect[MJDefine.MJOperateType.OPREATE_QIANG_GANG_HU])
  34. else
  35. sprite=cc.Sprite:create(xueliuAnimationCompnent.effect[MJDefine.MJOperateType.OPREATE_DIANPAOHU])
  36. end
  37. -- local bg = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_text_bg.png")
  38. -- sprite:addChild(bg,-1)
  39. -- local size= sprite:getContentSize()
  40. -- bg:setPosition(cc.p(size.width/2,size.height/2))
  41. sprite:setOpacity(150)
  42. sprite:setScale(0.5)
  43. local action={
  44. cc.Spawn:create(cc.EaseBackOut:create(cc.ScaleTo:create(0.2,1)),cc.FadeTo:create(0.2,255)),
  45. cc.DelayTime:create(0.2),
  46. cc.Spawn:create(cc.EaseBackIn:create(cc.ScaleTo:create(0.2,0)),cc.FadeTo:create(0.2,100)),
  47. cc.RemoveSelf:create(),
  48. cc.CallFunc:create(function()
  49. if callback then
  50. callback()
  51. end
  52. end),
  53. }
  54. sprite:runAction(cc.Sequence:create(action))
  55. return sprite
  56. end
  57. function xueliuAnimationCompnent.CreateHuOrderEffect(huType,order,callback)
  58. local orderNum = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_num"..order..".png")
  59. local sprite = nil
  60. if huType == MJDefine.MJGameHuType.HU_ZIMO then
  61. sprite=cc.Sprite:create(xueliuAnimationCompnent.effect[MJDefine.MJOperateType.OPREATE_ZIMOHU])
  62. orderNum:setPosition(cc.p(260,65))
  63. else
  64. sprite=cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_jiepao.png")
  65. orderNum:setPosition(cc.p(300,65))
  66. end
  67. sprite:addChild(orderNum)
  68. local bg = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_text_bg.png")
  69. sprite:addChild(bg,-1)
  70. local size= sprite:getContentSize()
  71. bg:setPosition(cc.p(size.width/2,size.height/2))
  72. sprite:setScale(0.5)
  73. local action={
  74. cc.DelayTime:create(0.2),
  75. cc.CallFunc:create(function()
  76. if callback then
  77. callback()
  78. end
  79. end),
  80. }
  81. sprite:runAction(cc.Sequence:create(action))
  82. return sprite
  83. end
  84. -- 爆牌
  85. function xueliuAnimationCompnent.CreateBaoEffect(callback)
  86. local sprite = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_baojiao.png")
  87. -- sprite:loadTexture("luzhou_effect_img_bao.png", 1)
  88. sprite:setOpacity(150)
  89. sprite:setScale(0.5)
  90. local bg = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_text_bg.png")
  91. sprite:addChild(bg,-1)
  92. local size= sprite:getContentSize()
  93. bg:setPosition(cc.p(size.width/2,size.height/2))
  94. local action = {
  95. cc.Spawn:create(cc.EaseBackOut:create(cc.ScaleTo:create(0.2,1)),cc.FadeTo:create(0.2,255)),
  96. cc.DelayTime:create(0.2),
  97. cc.Spawn:create(cc.EaseBackIn:create(cc.ScaleTo:create(0.2,0)),cc.FadeTo:create(0.2,100)),
  98. cc.CallFunc:create(function()
  99. if callback then
  100. callback()
  101. end
  102. end),
  103. cc.RemoveSelf:create(),
  104. }
  105. sprite:runAction(cc.Sequence:create(action))
  106. return sprite
  107. end
  108. -- 放炮
  109. function xueliuAnimationCompnent.CreateDianPaoEffect(callback)
  110. local sprite = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_fangpao.png")
  111. -- sprite:loadTexture("luzhou_effect_img_bao.png", 1)
  112. sprite:setOpacity(150)
  113. sprite:setScale(0.5)
  114. local action = {
  115. cc.Spawn:create(cc.EaseBackOut:create(cc.ScaleTo:create(0.2,1)),cc.FadeTo:create(0.2,255)),
  116. cc.DelayTime:create(0.2),
  117. cc.Spawn:create(cc.EaseBackIn:create(cc.ScaleTo:create(0.2,0)),cc.FadeTo:create(0.2,100)),
  118. cc.CallFunc:create(function()
  119. if callback then
  120. callback()
  121. end
  122. end),
  123. cc.RemoveSelf:create(),
  124. }
  125. sprite:runAction(cc.Sequence:create(action))
  126. return sprite
  127. end
  128. function xueliuAnimationCompnent.CreateStartSendCards(handViews,callback)
  129. local index=0
  130. local t=0.05
  131. local height=60
  132. local PCount = table.nums(handViews)
  133. for k,v in pairs(handViews) do
  134. for _,mj in pairs(v.handCards) do
  135. mj:setOpacity(0)--setVisible(false)
  136. end
  137. local startIndex=1
  138. local function nextAction()
  139. for i=startIndex,startIndex+3 do
  140. if v.handCards[i] then
  141. -- v.handCards[i]:setVisible(true)
  142. v.handCards[i]:setPositionY(v.handCards[i]:getPositionY()+height)
  143. v.handCards[i]:runAction(cc.EaseIn:create(cc.MoveBy:create(t,cc.p(0,-height)),t))
  144. v.handCards[i]:runAction(cc.FadeTo:create(t, 255))
  145. -- v.handCards[i]:runAction(cc.Sequence:create(cc.MoveBy:create(0.3,cc.p(0,-50)),cc.CallFunc(function()
  146. -- v.handCards[i]:setVisible(true)
  147. -- end)))
  148. end
  149. --[[if i==#v.handCards then
  150. v:stopAllActions()
  151. end--]]
  152. end
  153. startIndex=startIndex+4
  154. end
  155. local actions={
  156. cc.DelayTime:create(t*index),
  157. cc.CallFunc:create(nextAction),
  158. cc.DelayTime:create(t*PCount),
  159. cc.CallFunc:create(nextAction),
  160. cc.DelayTime:create(t*PCount),
  161. cc.CallFunc:create(nextAction),
  162. cc.DelayTime:create(t*PCount),
  163. cc.CallFunc:create(nextAction),
  164. }
  165. if index==table.nums(handViews)-1 then
  166. table.insert(actions,cc.DelayTime:create(0.3))
  167. table.insert(actions,cc.CallFunc:create(function()
  168. if callback then callback() end
  169. end))
  170. end
  171. v:runAction(cc.Sequence:create(actions))
  172. index=index+1
  173. end
  174. end
  175. -- 博自摸
  176. function xueliuAnimationCompnent.CreateBoZiMoEffect(callback)
  177. local sprite = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_bozimo.png")
  178. sprite:setOpacity(150)
  179. sprite:setScale(0.5)
  180. local bg = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_text_bg.png")
  181. sprite:addChild(bg,-1)
  182. local size= sprite:getContentSize()
  183. bg:setPosition(cc.p(size.width/2,size.height/2))
  184. local action = {
  185. cc.Spawn:create(cc.EaseBackOut:create(cc.ScaleTo:create(0.2,1)),cc.FadeTo:create(0.2,255)),
  186. cc.DelayTime:create(0.1),
  187. cc.Spawn:create(cc.EaseBackIn:create(cc.ScaleTo:create(0.2,0)),cc.FadeTo:create(0.2,100)),
  188. cc.CallFunc:create(function()
  189. if callback then
  190. callback()
  191. end
  192. end),
  193. cc.RemoveSelf:create(),
  194. }
  195. sprite:runAction(cc.Sequence:create(action))
  196. return sprite
  197. end
  198. -- 飘
  199. function xueliuAnimationCompnent.CreatePiaoEffect(callback, isRemoveSelf)
  200. isRemoveSelf = false
  201. local sprite = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_piao.png")
  202. sprite:setOpacity(150)
  203. sprite:setScale(isRemoveSelf and 0.5 or 0.3)
  204. local action={
  205. cc.Spawn:create(cc.EaseBackOut:create(cc.ScaleTo:create(0.3,isRemoveSelf and 1.0 or 0.5)),cc.FadeTo:create(0.3,255)),
  206. cc.DelayTime:create(0.1),
  207. 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)),
  208. cc.CallFunc:create(function()
  209. if callback then
  210. callback()
  211. end
  212. end),
  213. isRemoveSelf and cc.RemoveSelf:create()
  214. }
  215. sprite:runAction(cc.Sequence:create(action))
  216. return sprite
  217. end
  218. --刮风光效
  219. function xueliuAnimationCompnent.createGuaFengEffect()
  220. -- 加载第一张图片
  221. local nodeImage = cc.ImageView:createNode()
  222. nodeImage:loadTexture(string.format("guafeng_%d",0))
  223. -- 循环修改图片
  224. local everyFrame = 0.035
  225. local indexFace = 0
  226. local indexMax = 18
  227. local action1 = cc.Sequence:create(cc.DelayTime:create(everyFrame),cc.CallFunc:create(function ()
  228. indexFace = indexFace + 1
  229. if 0 < indexFace and indexFace < indexMax then
  230. else
  231. nodeImage:removeFromParent()
  232. return
  233. end
  234. local name = string.format("guafeng_%d.png",indexFace)
  235. if not tolua.isnull(nodeImage) then
  236. nodeImage:loadTexture(name, cc.TextureResType.plistType)
  237. end
  238. end))
  239. local action2 = cc.Repeat:create(action1, indexMax+1)
  240. --nodeImage:stopAllActions()
  241. --nodeImage:runAction(cc.RepeatForever:create(action2));
  242. nodeImage:runAction(action2)
  243. nodeImage:setVisible(true)
  244. return nodeImage
  245. end
  246. --下雨光效
  247. function xueliuAnimationCompnent.createXiaYuEffect()
  248. -- 加载第一张图片
  249. local nodeImage = cc.ImageView:createNode()
  250. nodeImage:loadTexture(string.format("xiayu-animation_%d",0))
  251. -- 循环修改图片
  252. local everyFrame = 0.035
  253. local indexFace = 0
  254. local indexMax = 16
  255. local action1 = cc.Sequence:create(cc.DelayTime:create(everyFrame),cc.CallFunc:create(function ()
  256. indexFace = indexFace + 1
  257. if 0 < indexFace and indexFace < indexMax then
  258. else
  259. nodeImage:removeFromParent()
  260. return
  261. end
  262. local name = string.format("xiayu-animation_%d.png",indexFace)
  263. if not tolua.isnull(nodeImage) then
  264. nodeImage:loadTexture(name, cc.TextureResType.plistType)
  265. end
  266. end))
  267. local action2 = cc.Repeat:create(action1, indexMax+1)
  268. --nodeImage:stopAllActions()
  269. --nodeImage:runAction(cc.RepeatForever:create(action2));
  270. nodeImage:runAction(action2)
  271. nodeImage:setVisible(true)
  272. return nodeImage
  273. end
  274. return xueliuAnimationCompnent