* Set collision type at tile position * 设置图块位置的碰撞类型 * @param col Column (X) | 列(X) * @param row Row (Y) | 行(Y) * @param collisionType Collision type (0 = none) | 碰撞类型(0表示无)
(col: number, row: number, collisionType: number)
| 862 | * @param collisionType Collision type (0 = none) | 碰撞类型(0表示无) |
| 863 | */ |
| 864 | setCollision(col: number, row: number, collisionType: number): void { |
| 865 | if (col < 0 || col >= this._width || row < 0 || row >= this._height) { |
| 866 | return; |
| 867 | } |
| 868 | if (this._collisionData.length === 0) { |
| 869 | this._collisionData = new Uint32Array(this._width * this._height); |
| 870 | this._collisionDataArray = new Array(this._width * this._height).fill(0); |
| 871 | } |
| 872 | const index = row * this._width + col; |
| 873 | this._collisionData[index] = collisionType; |
| 874 | this._collisionDataArray[index] = collisionType; |
| 875 | } |
| 876 | |
| 877 | /** |
| 878 | * Check collision at world coordinates |
no test coverage detected