feat: 支持手势引导
This commit is contained in:
@@ -48,10 +48,15 @@ export class PlayerController extends Component {
|
||||
// 道具列表
|
||||
private props: Node[] = [];
|
||||
|
||||
private guideNode: Node | null = null;
|
||||
|
||||
onLoad() {
|
||||
this.guideNode = this.canvas.node.getChildByName('Guide');
|
||||
|
||||
// 注册触摸事件
|
||||
input.on(Input.EventType.TOUCH_START, this.onTouchStart, this);
|
||||
|
||||
|
||||
let collider = this.player.getComponent(Collider2D);
|
||||
if (collider) {
|
||||
// 监听碰撞事件
|
||||
@@ -130,6 +135,8 @@ export class PlayerController extends Component {
|
||||
private onTouchStart(event: EventTouch) {
|
||||
if (!this.player || !this.camera || !this.pathfinder || this.isAttacking || this.isGameOver || this.isWin) return;
|
||||
|
||||
this.guideNode.active = false;
|
||||
|
||||
// 获取触摸点的UI坐标
|
||||
const touchLocation = event.getUILocation();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user