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.

94 lines
2.4 KiB

  1. --[[local CardNode = class("CardNode", function()
  2. return cc.ImageView:create()
  3. end)--]]
  4. local PokerUtil = require("zp_doushisi.luaScript.Views.Room.doushisiPokerUtil")
  5. local DoushisiRoomConfig = require("zp_doushisi.luaScript.Views.Room.doushisiRoomConfig")
  6. local ZPDef = ZPFramework.ZPImport("zp_base.luaScript.ZPDef")
  7. local doushisiQiPaiView = class("doushisiQiPaiView", function ()
  8. local node = cc.Node:create()
  9. return node
  10. end)
  11. function doushisiQiPaiView:ctor(viewId)
  12. self._viewId = viewId
  13. self._qiPaiValue = {}
  14. self._qiPaiNode = {}
  15. self.littleCardScale = 0.42
  16. end
  17. function doushisiQiPaiView:addQiPaiCard(card,isShowAni)
  18. local mSprite = cc.ImageView:createNode()
  19. mSprite:setScale(self.littleCardScale)
  20. local finalFileName = PokerUtil.pokerPng(card,ZPDef.CardType.CARD_TYPE_GROUP_OUT)
  21. mSprite:loadTextureFromPlist(finalFileName)
  22. mSprite:setVisible(not isShowAni)
  23. mSprite:setAnchorPoint(cc.p(0,0))
  24. mSprite.value = card
  25. self:addChild(mSprite)
  26. local pos = self:getQiPiaPosition()
  27. mSprite:setPosition(pos)
  28. table.insert(self._qiPaiNode,mSprite)
  29. table.insert(self._qiPaiValue,card)
  30. end
  31. function doushisiQiPaiView:getQiPiaPosition()
  32. local count = table.nums(self._qiPaiValue)
  33. local width = DoushisiRoomConfig.QICARD_WIDTH* self.littleCardScale;
  34. local height = DoushisiRoomConfig.QICARD_HEIGHT* self.littleCardScale;
  35. local getHeightCount = function (count)
  36. if count >= 6 then
  37. return math.floor(count/6)
  38. else
  39. return 0
  40. end
  41. end
  42. local x = 0
  43. x = count % 6
  44. local tarPos
  45. if self._viewId == 1 then
  46. local adjustPos = cc.p(width * x,height * getHeightCount(count))
  47. tarPos = cc.p(adjustPos.x,0 - adjustPos.y)
  48. elseif self._viewId == 2 then
  49. local adjustPos = cc.p(width * x,getHeightCount(count) * height)
  50. tarPos = cc.p(adjustPos.x,0 - adjustPos.y)
  51. elseif self._viewId == 3 then
  52. local adjustPos = cc.p(width * x,height * getHeightCount(count))
  53. tarPos = cc.p(0 + adjustPos.x,0 - adjustPos.y)
  54. elseif self._viewId == 4 then
  55. local adjustPos = cc.p(width * x,height * getHeightCount(count))
  56. tarPos = cc.p(adjustPos.x,0 - adjustPos.y)
  57. end
  58. return tarPos
  59. end
  60. function doushisiQiPaiView:showAllQiPaiCard()
  61. for k,v in pairs(self._qiPaiNode) do
  62. if not tolua.isnull(v) then
  63. v:setVisible(true)
  64. end
  65. end
  66. end
  67. function doushisiQiPaiView:reset()
  68. self._qiPaiValue = {}
  69. for k,v in pairs(self._qiPaiNode) do
  70. if not tolua.isnull(v) then
  71. v:removeFromParent()
  72. end
  73. end
  74. self._qiPaiNode = {}
  75. end
  76. return doushisiQiPaiView