CenterViewCtrl.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. m_NodeArray: {
  5. default: [],
  6. type: cc.Node
  7. },
  8. m_Clock: {
  9. default : [],
  10. type : cc.Label,
  11. },
  12. m_Rotation:[cc.Node],
  13. m_Back:cc.Node,
  14. },
  15. // use this for initialization
  16. onLoad: function () {
  17. if(this.node.getChildren().length <= 0) return;
  18. if(this.m_Clock.length <= 0)return;
  19. this.OnLoad = true;
  20. this.m_Clock[0].string = '0';
  21. this.m_Clock[1].string = '0';
  22. this.setCurrectUser(this.wCurrectUser);
  23. for (var i = 0; i < 4 ; i++) {
  24. this.m_Rotation[i].angle = i * 90;
  25. }
  26. },
  27. ctor: function (){
  28. this.wBankerUser = INVALID_CHAIR;
  29. this.wCurrectUser = INVALID_CHAIR;
  30. this.cbNum = 0;
  31. },
  32. updateNorth:function(){
  33. var UserCount = GameDef.GetPlayerCount();
  34. if( UserCount == 4 || UserCount == 2){
  35. var rot = GameDef.g_GameEngine.SwitchViewChairID(0);
  36. this.m_Back.angle = rot * 90;
  37. if( UserCount == 2 ){
  38. this.m_Rotation[1].active =false;
  39. this.m_Rotation[3].active =false;
  40. }
  41. }else if( UserCount == 3 ){
  42. this.m_Rotation[3].active = false;
  43. for (var i = 0; i < UserCount ; i++) {
  44. var rot = GameDef.g_GameEngine.SwitchViewChairID(i);
  45. this.m_Rotation[i].angle = rot * 90;
  46. }
  47. }
  48. },
  49. setCurrectUser:function(wChairID){
  50. this.wCurrectUser = wChairID;
  51. if( GameDef.GetPlayerCount() == 2 && wChairID == 1){
  52. wChairID = 2;
  53. }else{
  54. }
  55. for(var i in this.m_NodeArray){
  56. this.m_NodeArray[i].active=(i==wChairID);
  57. }
  58. },
  59. setTimerNum:function(bShow,cbNum){
  60. var cbTmp = (cbNum>0)?1:0;
  61. //cbNum = parseInt(cbNum/20);
  62. if(this.cbNum==cbNum)return;
  63. this.cbNum = cbNum+cbTmp;
  64. this.m_Clock[0].string = parseInt(cbNum / 10);
  65. this.m_Clock[1].string = cbNum % 10;
  66. this.m_Clock[0].node.active = bShow;
  67. this.m_Clock[1].node.active = bShow;
  68. return this.cbNum;
  69. },
  70. // called every frame, uncomment this function to activate update callback
  71. // update: function (dt) {
  72. // },
  73. });