Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Commit

Permalink
fix: update input code (#760)
Browse files Browse the repository at this point in the history
  • Loading branch information
cptbtptpbcptdtptp authored Jul 6, 2023
1 parent 5621b85 commit 6c88ec8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ The following example:

### Q & A

#### 0. Why is the touch function normal on the PC side, but abnormal on the mobile side?

On the mobile side, touch will trigger the default behavior of HTML elements. Once the default behavior is triggered, the touch will be removed from the element (pointercancel), which can be solved by setting `touchAction` of the canvas:

```typescript
(engine.canvas._webCanvas as HTMLCanvasElement).style.touchAction = "none";
```

#### 1. How to troubleshoot why the Entity is not detected by the touch point
- **Physics engine**: Please ensure that the physics engine is initialized at the same time as the engine is initialized.
- **Collision component**: Please ensure that the Entity contains the Collision component, and the shape of the collision body fits the range of the collision.
Expand Down
8 changes: 8 additions & 0 deletions docs/input.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ Pointer 则表示每个独立的光标实例,通过调用相关的方法可以

### Q & A

#### 0. 为什么触控在 PC 端正常,但是在移动端异常

在移动端,触控会触发 HTML 元素的默认行为,一旦触发默认行为,触控就会从元素上被移除(pointercancel),可以通过设置画布的 `touchAction` 解决:

```typescript
(engine.canvas._webCanvas as HTMLCanvasElement).style.touchAction = "none";
```

#### 1. 如何排查为何 Entity 没被触控点检测到?

- **物理引擎**:请保证初始化引擎的同时初始化物理引擎。
Expand Down

0 comments on commit 6c88ec8

Please sign in to comment.