Step1.ts 914 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import EventListener from "../../../util/EventListener";
  2. /**
  3. * 地图1 剧情1
  4. */
  5. const { ccclass, property } = cc._decorator;
  6. @ccclass
  7. export default class Step1 extends cc.Component {
  8. @property({
  9. displayName: "小矮人",
  10. type: cc.Node,
  11. })
  12. npc_1: cc.Node = null;
  13. onLoad() {
  14. EventListener.on("Step1", this.npcJump, this);
  15. }
  16. onDestroy() {
  17. EventListener.off("Step1", this.npcJump, this);
  18. }
  19. start() {
  20. if (this.npc_1) {
  21. this.npc_1.active = false;
  22. }
  23. }
  24. npcJump() {
  25. if (this.npc_1) {
  26. this.npc_1.active = true;
  27. cc.tween(this.npc_1).sequence(
  28. cc.moveTo(0.5, cc.v2(this.npc_1.x + 300, this.npc_1.y)),
  29. cc.callFunc(() => {
  30. console.log("======小矮人跳出来======")
  31. })
  32. ).start();
  33. }
  34. }
  35. }