Step1.ts 833 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. start() {
  17. if (this.npc_1) {
  18. this.npc_1.active = false;
  19. }
  20. }
  21. npcJump() {
  22. if (this.npc_1) {
  23. this.npc_1.active = true;
  24. cc.tween(this.npc_1).sequence(
  25. cc.moveTo(0.5, cc.v2(this.npc_1.x + 300, this.npc_1.y)),
  26. cc.callFunc(() => {
  27. console.log("======小矮人跳出来======")
  28. })
  29. ).start();
  30. }
  31. }
  32. }