move.ts 705 B

1234567891011121314151617181920212223242526272829
  1. import { GameLogic } from "./GameLogic";
  2. const {ccclass, property} = cc._decorator;
  3. @ccclass
  4. export default class Move extends GameLogic {
  5. private _speed: number = 100;
  6. public get speed(): number {
  7. return this._speed;
  8. }
  9. public set speed(value: number) {
  10. this._speed = value;
  11. }
  12. private _dirction: cc.Vec2 = cc.v2(0, 0);
  13. public get dirction(): cc.Vec2 {
  14. return this._dirction;
  15. }
  16. public set dirction(value: cc.Vec2) {
  17. this._dirction = value;
  18. }
  19. gameUpdate(dt: number): void {
  20. this.node.x += this.speed * dt * this.dirction.x;
  21. this.node.y += this.speed * dt * this.dirction.y;
  22. }
  23. }