UserProp.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 { PopName } from "../EventName/EventName";
  8. import LocalData from "../Template/LocalData";
  9. import PopComponet from "../Template/PopComponet";
  10. import PopManger from "./PopManger";
  11. const { ccclass, property } = cc._decorator;
  12. @ccclass
  13. export default class UserProp extends PopComponet {
  14. @property(cc.SpriteFrame)
  15. Time: cc.SpriteFrame = null
  16. @property(cc.SpriteFrame)
  17. Jump: cc.SpriteFrame = null
  18. @property(cc.Label)
  19. PropDetails: cc.Label = null
  20. NoThanks() {
  21. this.Surpclose()
  22. }
  23. GetProp() {
  24. switch (this.Options.PropType) {
  25. case 0://时间
  26. LocalData.getInstance().AddTimeStopCount()
  27. break;
  28. case 1://跳跃
  29. LocalData.getInstance().AddNowSitDownCount()
  30. break;
  31. default:
  32. console.error('错误了');
  33. break;
  34. }
  35. this.Surpclose()
  36. }
  37. protected start(): void {
  38. let image = this.node.getChildByName("Node").getChildByName("image").getComponent(cc.Sprite)
  39. switch (this.Options.PropType) {
  40. case 0://时间
  41. image.spriteFrame = this.Time
  42. this.PropDetails.string = '它能延长时间十秒'
  43. break;
  44. case 1://跳跃
  45. image.spriteFrame = this.Jump
  46. this.PropDetails.string = '它能让一个乘客跳跃'
  47. break;
  48. default:
  49. console.error('错误了');
  50. break;
  51. }
  52. }
  53. }