super-hero/assets/cc-game/scripts/game_play/hero/HeroMove.ts

19 lines
626 B
TypeScript

import { Vec3 } from 'cc';
import { _decorator, Component, Node } from 'cc';
import { UmUtil } from '../../../../cc-common/cc-util/UmUtil';
import { GameGlobalData } from '../../global/GameGlobalData';
const { ccclass, property } = _decorator;
@ccclass('HeroMove')
export class HeroMove extends Component {
directionVec3: Vec3 = Vec3.ZERO;
isTouchEnable = false;
update(deltaTime: number) {
if (!this.isTouchEnable || this.directionVec3 === Vec3.ZERO || !GameGlobalData.Instance.isStatePlay()) return;
this.node.position = UmUtil.plusTwoVector3(this.node.position, this.directionVec3);
}
}