Game.ts 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import FunBtns from "./FunBtns";
  2. const { ccclass, property } = cc._decorator;
  3. @ccclass
  4. export default class Game extends cc.Component {
  5. @property({ type: cc.Node, displayName: "游戏核心" })
  6. node_game: cc.Node = null;
  7. @property({ type: cc.Node, displayName: "功能按钮" })
  8. node_btn: cc.Node = null;
  9. @property({ type: cc.Sprite, displayName: "头像" })
  10. img_head: cc.Sprite = null;
  11. @property({ type: cc.Label, displayName: "红包币" })
  12. lbl_redMoney: cc.Label = null;
  13. @property({ type: cc.Label, displayName: "金猪币" })
  14. lbl_rmb: cc.Label = null;
  15. @property({ type: cc.Sprite, displayName: "红包提现" })
  16. btn_cashOutNormal: cc.Sprite = null;
  17. @property({ type: cc.Sprite, displayName: "金猪提现" })
  18. btn_cashOutGold: cc.Sprite = null;
  19. @property({ type: cc.Node, displayName: "气泡红包1" })
  20. btn_getRed1: cc.Node = null;
  21. @property({ type: cc.Node, displayName: "气泡红包2" })
  22. btn_getRed2: cc.Node = null;
  23. @property({ type: cc.Node, displayName: "气泡红包3" })
  24. btn_getRed3: cc.Node = null;
  25. @property({ type: cc.Button, displayName: "开始游戏" })
  26. btn_start: cc.Button = null;
  27. @property({ type: cc.RichText, displayName: "公告" })
  28. rich_cast: cc.RichText = null;
  29. onLoad() {
  30. mk.ui.closePanel("login");
  31. }
  32. start() {
  33. this.initMusic();
  34. this.initBtns();
  35. this.initQiPaos();
  36. }
  37. private initMusic() {
  38. mk.audio.playMusic("bgm");
  39. }
  40. /**
  41. * 根据配置,添加开启的功能按钮
  42. */
  43. private initBtns() {
  44. let sc = this.node_btn.getComponent(FunBtns) as FunBtns;
  45. sc.init();
  46. }
  47. private initQiPaos() {
  48. cc.tween(this.btn_getRed1).to(2, { y: 100 }).to(2, { y: 0 }).repeatForever().start();
  49. cc.tween(this.btn_getRed2).delay(0.3).to(2, { y: 100 }).to(2, { y: 0 }).repeatForever().start();
  50. cc.tween(this.btn_getRed3).delay(0.6).to(2, { y: -50 }).to(2, { y: -150 }).repeatForever().start();
  51. }
  52. //测试道具获取效果
  53. private testFly() {
  54. mk.fly.PlayCoinAnim(10001, 20, cc.v2(0, -300), cc.v2(0, 0));
  55. // mk.fly.PlayCoinAnim(10002, 20, cc.v2(0, -300), 'Canvas/界面层/game/功能按钮/右侧按钮/btn2');
  56. }
  57. update() {
  58. }
  59. }