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

19 lines
646 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';
import { JoyStick } from '../../../Test/JoyStick';
const { ccclass, property } = _decorator;
@ccclass('HeroMove')
export class HeroMove extends Component {
isTouchEnable = false;
update(deltaTime: number) {
if (!JoyStick.IS_TOUCH_ENABLE || JoyStick.DIRECTION === Vec3.ZERO || !GameGlobalData.Instance.isStatePlay()) return;
this.node.position = UmUtil.plusTwoVector3(this.node.position, JoyStick.DIRECTION);
}
}