您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

397 行
12 KiB

  1. local MJDefine=MJFramework.MJImport("mj.luaScript.MJDefine")
  2. local MJ=MJFramework.MJImport("mj.luaScript.Views.Game.MJ")
  3. local zigongAnimationCompnent = MJFramework.MJFrameworkClassImprot("mj.luaScript.Views.Compnent.MJAnimationCompnent")
  4. function zigongAnimationCompnent.CreateOperareEffect(opType,callback)
  5. if zigongAnimationCompnent.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(zigongAnimationCompnent.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 zigongAnimationCompnent.CreateHuEffect(huType,callback)
  29. local sprite
  30. if huType == MJDefine.MJGameHuType.HU_ZIMO then
  31. sprite=cc.Sprite:create(zigongAnimationCompnent.effect[MJDefine.MJOperateType.OPREATE_ZIMOHU])
  32. elseif huType == MJDefine.MJGameHuType.HU_QIANGGANG then
  33. sprite=cc.Sprite:create(zigongAnimationCompnent.effect[MJDefine.MJOperateType.OPREATE_QIANG_GANG_HU])
  34. else
  35. sprite=cc.Sprite:create(zigongAnimationCompnent.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 zigongAnimationCompnent.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(zigongAnimationCompnent.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 zigongAnimationCompnent.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 zigongAnimationCompnent.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 zigongAnimationCompnent.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 zigongAnimationCompnent.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 zigongAnimationCompnent.CreateLoBoEffect(card,desktopType,callback)
  200. if desktopType == MJDefine.DesktopType.ThreeD then
  201. desktopType = MJDefine.DesktopType.TwoD
  202. end
  203. local mj=MJ:new(0,MJDefine.MJType.Out,MJDefine.MyViewId,desktopType)
  204. mj:setScale(1.5)
  205. local action = {
  206. cc.MoveBy:create(0.3,cc.p(0,25)),
  207. cc.CallFunc:create(function()
  208. local lightEffect = zigongAnimationCompnent.createLuoBoLightEffect()
  209. local mjSize = mj:getContentSize()
  210. lightEffect:setPosition(cc.p(mjSize.width/2,mjSize.height/2+5))
  211. mj:addChild(lightEffect)
  212. local newValue=string.format("%x",card)
  213. mj:setOutImage(newValue,MJDefine.MyViewId)
  214. local sprite = cc.Sprite:createWithSpriteFrameName("zg_room_luoboyezi.png")
  215. sprite:setScale(0.6)
  216. sprite:setPosition(cc.p(mjSize.width/2-2,mjSize.height+8))
  217. mj:addChild(sprite,-1)
  218. end),
  219. cc.DelayTime:create(0.3),--光效时间
  220. --cc.DelayTime:create(3.0),--停留时间(播完光效停留几秒进入小局)
  221. cc.CallFunc:create(function()
  222. if callback then
  223. callback()
  224. end
  225. end),
  226. --cc.RemoveSelf:create(),
  227. }
  228. mj:runAction(cc.Sequence:create(action))
  229. return mj
  230. end
  231. --萝卜光效
  232. function zigongAnimationCompnent.createLuoBoLightEffect()
  233. -- 加载第一张图片
  234. local nodeImage = cc.ImageView:createNode()
  235. nodeImage:loadTexture(string.format("luobo-texiao_%d",0))
  236. -- 循环修改图片
  237. local everyFrame = 0.025
  238. local indexFace = 0
  239. local indexMax = 14
  240. local action1 = cc.Sequence:create(cc.DelayTime:create(everyFrame),cc.CallFunc:create(function ()
  241. indexFace = indexFace + 1
  242. if 0 < indexFace and indexFace < indexMax then
  243. else
  244. nodeImage:removeFromParent()
  245. return
  246. end
  247. local name = string.format("luobo-texiao_%d.png",indexFace)
  248. if not tolua.isnull(nodeImage) then
  249. nodeImage:loadTexture(name, cc.TextureResType.plistType)
  250. end
  251. end))
  252. local action2 = cc.Repeat:create(action1, indexMax+1)
  253. --nodeImage:stopAllActions()
  254. --nodeImage:runAction(cc.RepeatForever:create(action2));
  255. nodeImage:runAction(action2)
  256. nodeImage:setVisible(true)
  257. return nodeImage
  258. end
  259. --静态萝卜数量
  260. function zigongAnimationCompnent.CreateLoBoLabel(num,callback)
  261. local sprite = cc.Sprite:createWithSpriteFrameName("zg_room_luobo.png")
  262. local txtX = cc.TextBMFont:createNode()
  263. txtX:setFntFile("res/fonts/luobonum.fnt")
  264. txtX:setString("*")
  265. txtX:setLocalZOrder(1001)
  266. sprite:addChild(txtX)
  267. local txt = cc.TextBMFont:createNode()
  268. txt:setFntFile("res/fonts/luobonum.fnt")
  269. txt:setString(string.format("%d", num))
  270. --txt:setTag(166)
  271. txt:setLocalZOrder(1001)
  272. sprite:addChild(txt)
  273. local size= sprite:getContentSize()
  274. txtX:setPosition(cc.p(size.width+22,size.height/2-5))
  275. txt:setPosition(cc.p(size.width+55,size.height/2+5))
  276. local action = {
  277. cc.DelayTime:create(1.5),
  278. cc.CallFunc:create(function()
  279. if callback then
  280. callback()
  281. end
  282. end),
  283. }
  284. sprite:runAction(cc.Sequence:create(action))
  285. return sprite
  286. end
  287. -- 飘
  288. function zigongAnimationCompnent.CreatePiaoEffect(callback, isRemoveSelf)
  289. isRemoveSelf = false
  290. local sprite = cc.Sprite:create("mj/res/ui/zy_fangjian/operate/mj_effect_piao.png")
  291. sprite:setOpacity(150)
  292. sprite:setScale(isRemoveSelf and 0.5 or 0.3)
  293. local action={
  294. cc.Spawn:create(cc.EaseBackOut:create(cc.ScaleTo:create(0.3,isRemoveSelf and 1.0 or 0.5)),cc.FadeTo:create(0.3,255)),
  295. cc.DelayTime:create(0.1),
  296. 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)),
  297. cc.CallFunc:create(function()
  298. if callback then
  299. callback()
  300. end
  301. end),
  302. isRemoveSelf and cc.RemoveSelf:create()
  303. }
  304. sprite:runAction(cc.Sequence:create(action))
  305. return sprite
  306. end
  307. --刮风光效
  308. function zigongAnimationCompnent.createGuaFengEffect()
  309. -- 加载第一张图片
  310. local nodeImage = cc.ImageView:createNode()
  311. nodeImage:loadTexture(string.format("guafeng_%d",0))
  312. -- 循环修改图片
  313. local everyFrame = 0.035
  314. local indexFace = 0
  315. local indexMax = 18
  316. local action1 = cc.Sequence:create(cc.DelayTime:create(everyFrame),cc.CallFunc:create(function ()
  317. indexFace = indexFace + 1
  318. if 0 < indexFace and indexFace < indexMax then
  319. else
  320. nodeImage:removeFromParent()
  321. return
  322. end
  323. local name = string.format("guafeng_%d.png",indexFace)
  324. if not tolua.isnull(nodeImage) then
  325. nodeImage:loadTexture(name, cc.TextureResType.plistType)
  326. end
  327. end))
  328. local action2 = cc.Repeat:create(action1, indexMax+1)
  329. --nodeImage:stopAllActions()
  330. --nodeImage:runAction(cc.RepeatForever:create(action2));
  331. nodeImage:runAction(action2)
  332. nodeImage:setVisible(true)
  333. return nodeImage
  334. end
  335. --下雨光效
  336. function zigongAnimationCompnent.createXiaYuEffect()
  337. -- 加载第一张图片
  338. local nodeImage = cc.ImageView:createNode()
  339. nodeImage:loadTexture(string.format("xiayu-animation_%d",0))
  340. -- 循环修改图片
  341. local everyFrame = 0.035
  342. local indexFace = 0
  343. local indexMax = 16
  344. local action1 = cc.Sequence:create(cc.DelayTime:create(everyFrame),cc.CallFunc:create(function ()
  345. indexFace = indexFace + 1
  346. if 0 < indexFace and indexFace < indexMax then
  347. else
  348. nodeImage:removeFromParent()
  349. return
  350. end
  351. local name = string.format("xiayu-animation_%d.png",indexFace)
  352. if not tolua.isnull(nodeImage) then
  353. nodeImage:loadTexture(name, cc.TextureResType.plistType)
  354. end
  355. end))
  356. local action2 = cc.Repeat:create(action1, indexMax+1)
  357. --nodeImage:stopAllActions()
  358. --nodeImage:runAction(cc.RepeatForever:create(action2));
  359. nodeImage:runAction(action2)
  360. nodeImage:setVisible(true)
  361. return nodeImage
  362. end
  363. return zigongAnimationCompnent