tile Kind At

Check if the type of tile next to the sprite is of a specific kind

mySpritetile toleftofis
JavaScript
(method) Sprite.tileKindAt(direction: TileDirection, tile: Image): boolean;
Python
(method) Sprite.tile_kind_at(direction: TileDirection, tile: Image): bool

You can check to see if the tiles next to or under your sprite have a specific tile image. A boolean is returned.

Parameters

  • direction: the direction of the tile, relative to the sprite: left, right, top, bottom, or center (directly under your sprite).
  • image: the chosen tile image

Returns

  • a boolean which indicates whether the tile has the specified image.

Example

Build a brick wall of tiles in the scene. Send a arrow sprite towards the wall. When the sprite hits the wall, say what type of tile it contacted.

flipImagePlayerspriteof kindmySprite-50setvx (velocity x)tosetmySpritetosetflipImagetoscene.setTile(2, img`1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 f 2 1 1 2 2 f 2 2 2 2 2 2 2 2 2 2 2 1 1 2 2 2 2 2 2 f 2 2 2 2 2 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 f 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 2 2 2 2 f 2 2 2 f 2 2 2 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 2 2 f 2 2 2 2 2 2 2 2 f 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 1 2 2 2 2 2 2 f 2 2 2 2 f 2 2 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 1 `, true)scene.onHitTile(SpriteKind.Player, 2, function (sprite) {    sprite.say("tile: " + sprite.tileHitFrom(CollisionDirection.Left))})on start

See also

is hitting tile, on overlap tile on hit wall