This advanced method is specifically for testing for collision between a single Sprite and an array of Tile objects.
You should generally use the collide
method instead, with a Sprite vs. a Tilemap Layer, as that will perform
tile filtering and culling for you, as well as handle the interesting face collision automatically.
This method is offered for those who would like to check for collision with specific Tiles in a layer, without having to set any collision attributes on the tiles in question. This allows you to perform quick dynamic collisions on small sets of Tiles. As such, no culling or checks are made to the array of Tiles given to this method, you should filter them before passing them to this method.
Important: Use of this method skips the interesting faces
system that Tilemap Layers use. This means if you have
say a row or column of tiles, and you jump into, or walk over them, it's possible to get stuck on the edges of the
tiles as the interesting face calculations are skipped. However, for quick-fire small collision set tests on
dynamic maps, this method can prove very useful.
name | type | arguments | description |
---|---|---|---|
sprite | Phaser.GameObjects.GameObject |
The first object to check for collision. |
|
tiles | Array.<Phaser.Tilemaps.Tile> |
An array of Tiles to check for collision against. |
|
collideCallback | Phaser.Types.Physics.Arcade.ArcadePhysicsCallback | <optional> |
An optional callback function that is called if the objects collide. |
processCallback | Phaser.Types.Physics.Arcade.ArcadePhysicsCallback | <optional> |
An optional callback function that lets you perform additional checks against the two objects if they collide. If this is set then |
callbackContext | any | <optional> |
The context in which to run the callbacks. |
True if any objects overlap (with overlapOnly
); or true if any overlapping objects were separated.