layoutManager.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. // Learn cc.Class:
  2. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
  3. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
  4. // Learn Attribute:
  5. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
  6. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
  7. // Learn life-cycle callbacks:
  8. // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
  9. // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
  10. cc.Class({
  11. extends: cc.Component,
  12. properties: {
  13. // foo: {
  14. // // ATTRIBUTES:
  15. // default: null, // The default value will be used only when the component attaching
  16. // // to a node for the first time
  17. // type: cc.SpriteFrame, // optional, default is typeof default
  18. // serializable: true, // optional, default is true
  19. // },
  20. // bar: {
  21. // get () {
  22. // return this._bar;
  23. // },
  24. // set (value) {
  25. // this._bar = value;
  26. // }
  27. // },
  28. },
  29. // LIFE-CYCLE CALLBACKS:
  30. // onLoad () {},
  31. start() {
  32. utils.isMobile(function () {
  33. Manager.layoutManager = this;
  34. }.bind(this));
  35. this.initPlayer();
  36. Global.layoutManager = this;
  37. },
  38. initPlayer: function () {
  39. let player = this.player = UtilsPrefabs.getNode("player", this.node);
  40. let icmask = UtilsPrefabs.getNode("icmask", player);
  41. let ic = UtilsPrefabs.getNode("ic", icmask);
  42. //设置头像
  43. utils.loadHttpSpriteFrame(UserInfo.Player.head, ic.getComponent(cc.Sprite));
  44. //设置名字
  45. let name = UtilsPrefabs.getNode("name", player);
  46. name.getComponent(cc.Label).string = UserInfo.Player.name;
  47. let dialog = this.dialog = UtilsPrefabs.getNode("dialog", this.node);
  48. let bg = UtilsPrefabs.getNode("bg", dialog);
  49. Global.strike.setOnGameoverCallBack(function () {
  50. console.log("游戏真的结束了");
  51. Global.gameover = true;
  52. }.bind(this));
  53. //游戏结束
  54. // Global.strike.setOnGameoverCallBack(function () {
  55. //
  56. // //
  57. //
  58. // dialog.active = true;
  59. //
  60. // utils.isMobile(function () {
  61. // Manager.gameover();
  62. // }.bind(this));
  63. // }.bind(this));
  64. UtilsPrefabs.setOn(bg, function () {
  65. // UtilsPrefabs.setOff(bg);
  66. this.showRankingList();
  67. }.bind(this))
  68. },
  69. setGameOver : function(){
  70. // this.dialog.active = true;
  71. //
  72. // utils.isMobile(function () {
  73. // Manager.gameover();
  74. // }.bind(this));
  75. this.dialog.active = false;
  76. utils.isMobile(function () {
  77. Manager.gameover();
  78. //真的数据来了 就注释此行
  79. // this.showRankingList();
  80. }.bind(this));
  81. utils.isWeb(function () {
  82. this.showRankingList();
  83. }.bind(this));
  84. // this.showRankingList();
  85. },
  86. //显示排行榜
  87. showRankingList: function () {
  88. // if (this.dialog.active == false) {
  89. // return;
  90. // }
  91. //去分享页面
  92. utils.toLoadScene("Multi_function");
  93. }
  94. // update (dt) {},
  95. });