Award.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Learn TypeScript:
  2. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
  3. // Learn Attribute:
  4. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
  5. // Learn life-cycle callbacks:
  6. // - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
  7. import AudioManager from "../AudioManager";
  8. import EventName from "../EventName/EventName";
  9. import LocalData from "../LocalData";
  10. import MyComponent from "../Template/MyComponent";
  11. import RewardMnr from "../Template/RewardMnr";
  12. const { ccclass, property } = cc._decorator;
  13. @ccclass
  14. export default class Award extends MyComponent {
  15. @property(cc.SpriteFrame)
  16. XuXian: cc.SpriteFrame = null
  17. @property(cc.SpriteFrame)
  18. ChaojiTiao: cc.SpriteFrame = null
  19. @property(cc.SpriteFrame)
  20. Fly: cc.SpriteFrame = null
  21. onEnable(): void {
  22. let guang = this.node.getChildByName("guang")
  23. cc.tween(guang)
  24. .to(0, { angle: 0 })
  25. .to(3 * 1000, { angle: 360 * 1000 })
  26. .start()
  27. }
  28. protected onDisable(): void {
  29. this.unscheduleAllCallbacks()
  30. }
  31. setSp(num: AwardType) {
  32. console.log(num);
  33. let a = this.node.getChildByName("wushizhongli").getComponent(cc.Sprite)
  34. switch (num) {
  35. case 1:
  36. a.spriteFrame = this.XuXian
  37. RewardMnr.getInstance().PropUseParabola(1)
  38. break;
  39. case 2:
  40. a.spriteFrame = this.ChaojiTiao
  41. break;
  42. case 3:
  43. a.spriteFrame = this.Fly
  44. break;
  45. default:
  46. break;
  47. }
  48. }
  49. }
  50. export enum AwardType {
  51. XuXian = 1,
  52. ChaojiTiao = 2,
  53. Fly = 3
  54. }