gamelayoutManager.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. //进度条 要做 人头像 和进度条联动
  33. let progressBar = this.progressBar = UtilsPrefabs.getNode("progressBar", this.node);
  34. //打击次数
  35. let powcountlayout = this.powcountlayout = UtilsPrefabs.getNode("powcountlayout", this.node);
  36. let bar = UtilsPrefabs.getNode("bar", progressBar);
  37. let icmask =this.icmask = UtilsPrefabs.getNode("icmask", bar);
  38. let icmaskic =this.icmaskic = UtilsPrefabs.getNode("icmaskic", icmask);
  39. let ic =this.ic = UtilsPrefabs.getNode("ic", icmaskic);
  40. //设置头像
  41. utils.loadHttpSpriteFrame(UserInfo.Player.head, ic.getComponent(cc.Sprite));
  42. },
  43. //设置 打击次数 的变化
  44. setPowcount : function (callback) {
  45. let count = 0;
  46. // console.log("里面是什么",this.powcountlayout.children);
  47. // for (var i = this.powcountlayout.children.length-1; i >=0; i--) {
  48. for (var i = 0; i <this.powcountlayout.children.length; i++) {
  49. let temp = this.powcountlayout.children[i];
  50. if (temp.mytag == null) {
  51. // temp.children[0].active = false;
  52. temp.children[0].getComponent(cc.Animation).play();
  53. let thisOneScoreLabel = UtilsPrefabs.getNode("Score", temp.children[1]);
  54. thisOneScoreLabel.getComponent(cc.Label).string = Math.floor(this.thisOneScore);
  55. let showdata = UtilsPrefabs.getNode("showdata", temp.children[1]);
  56. UtilsPrefabs.getNode("der", showdata).getComponent(cc.Label).string = this.showData.der;
  57. UtilsPrefabs.getNode("pianyi", showdata).getComponent(cc.Label).string = this.showData.pianyi;
  58. UtilsPrefabs.getNode("power", showdata).getComponent(cc.Label).string = this.showData.power;
  59. UtilsPrefabs.getNode("ballSpeed", showdata).getComponent(cc.Label).string = this.showData.ballSpeed;
  60. //测试数据显示隐藏
  61. showdata.active = false;
  62. // utils.loadResSpriteFrame("kuang",function (texture) {
  63. // temp.getComponent(cc.Sprite).spriteFrame = texture;
  64. //
  65. // }.bind(this));
  66. temp.mytag = 1;
  67. break;
  68. }
  69. count++;
  70. }
  71. if (count == this.powcountlayout.children.length-1) {
  72. if (callback != null) {
  73. callback();
  74. }
  75. }
  76. },
  77. //设定飞行距离的变化
  78. setFlyKM : function (progress) {
  79. // console.log("设置了",progress);
  80. this.progressBar.getComponent(cc.ProgressBar).progress =progress;
  81. let bar = UtilsPrefabs.getNode("bar", this.progressBar);
  82. let wi = bar.height;
  83. this.icmask.y = wi;
  84. // Global.layoutManager.player.y= wi;
  85. },
  86. getFlyKM : function () {
  87. return this.progressBar.getComponent(cc.ProgressBar).progress;
  88. }
  89. // update (dt) {},
  90. });