FaceExCtrl.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. cc.Class({
  2. extends: cc.BaseClass,
  3. properties: {
  4. m_SelNode:cc.Node,
  5. },
  6. ctor :function(){
  7. this.m_AniArr = new Array(
  8. 'beer',
  9. 'egg',
  10. 'shot',
  11. 'kiss',
  12. 'woshou',
  13. 'rose',
  14. 'bomb',
  15. );
  16. this.m_GameSound = new Array(
  17. ['shot', 'Audio/shot'],
  18. ['rose', 'Audio/rose'],
  19. ['egg', 'Audio/egg'],
  20. ['beer', 'Audio/beer'],
  21. ['bomb', 'Audio/bomb'],
  22. ['kiss', 'Audio/kiss'],
  23. );
  24. },
  25. onLoad:function () {
  26. cc.gPreLoader.LoadPrefab("FaceExAni");
  27. //this.m_AniPool = new cc.NodePool('FaceExAniPool');
  28. cc.gSoundRes.LoadSoundArr(this.m_GameSound, 'Chat_2');
  29. this.m_AniPreArr = new Array();
  30. this.m_SelNode.active = false;
  31. },
  32. PlayAni:function (CallBack) {
  33. //�����
  34. for(var i=0;i<this.m_AniPreArr.length;i++){
  35. if(!this.m_AniPreArr[i].node.active){
  36. this.m_AniPreArr[i].node.active = true;
  37. return CallBack(this.m_AniPreArr[i])
  38. }
  39. }
  40. var AniIndex = this.m_AniPreArr.length;
  41. cc.gPreLoader.LoadPrefab("FaceExAni", function(Js){
  42. this.node.addChild(Js.node);
  43. this.m_AniPreArr[AniIndex] = Js;
  44. this.m_AniPreArr[AniIndex].Init(this);
  45. this.m_AniPreArr[AniIndex].node.active = true;
  46. CallBack(this.m_AniPreArr[AniIndex])
  47. }.bind(this));
  48. },
  49. SetShowInfo:function(UserID, ChairID, IP){
  50. this.m_SelNode.active = true;
  51. this.$('SelNode/UserCtrl@UserCtrl').SetUserByID(UserID);
  52. this.TagUser = UserID;
  53. this.TagChairID = ChairID;
  54. this.$('SelNode/UserCtrl/IP/Label@Label').string = IP;
  55. /*var webUrl = 'http://ip-api.com/json/?lang=zh-CN';
  56. WebCenter.GetData(webUrl, null, function (data) {
  57. var res = JSON.parse(data);
  58. this.$('SelNode/UserCtrl/Adress/adress@Label').string = res.city
  59. //this.$('SelNode/UserCtrl/IP/Label@Label').string = res.query
  60. }.bind(this));
  61. var webUrl2 = window.PHP_HOME+'/UserFunc.php?&GetMark=18&dwUserID='+UserID;
  62. WebCenter.GetData(webUrl2, 10, function (data) {
  63. var res = JSON.parse(data);
  64. this.$('SelNode/UserCtrl/JuShu/jushu@Label').string = res.GameCnt;
  65. this.$('SelNode/UserCtrl/Time/time@Label').string = res.Time;
  66. }.bind(this));*/
  67. },
  68. OnHideSelNode:function(){
  69. this.m_SelNode.active = false;
  70. },
  71. OnBtClickedFaceEx:function(Tag, Data){
  72. this.m_Hook.m_GameClientEngine.OnSendPhrase(parseInt(Data)+2000, this.TagUser)
  73. this.OnHideSelNode();
  74. },
  75. OnSendFaceEx:function(SendUser, TagUser, AniIndex){
  76. if(AniIndex < 2000 || AniIndex > 3000) return;
  77. var realIndex = AniIndex-2000-1;
  78. this.PlayAni(function(AniPre){
  79. AniPre.node.setPosition( this.m_Hook.m_UserFaceArr[SendUser]);
  80. AniPre.PlayAni(this.m_AniArr[realIndex], this.m_Hook.m_UserFaceArr[TagUser]);
  81. cc.gSoundRes.PlaySound(this.m_AniArr[realIndex]);
  82. }.bind(this));
  83. },
  84. AniFinish:function (Js) {
  85. Js.node.active = false;
  86. },
  87. });