MCPcopy Create free account
hub / github.com/esengine/esengine / setCollision

Method setCollision

packages/tilemap/src/TilemapComponent.ts:864–875  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers 4

floodFillMethod · 0.80
eraseMethod · 0.80
fillRectangleMethod · 0.80
paintMethod · 0.80

Calls 1

fillMethod · 0.80

Tested by

no test coverage detected