Get number of columns and rows in tilemap

Based on this question,

I can make a tilemap to be a certain number of columns and rows, but once it’s made, I cannot see a block function to get those values. I have to remember what those values are for each tilemap and then find a location at col/row coordinates.

Knowing the number of columns and rows in block code, I could then place sprites within the timemap (bottom of tile map in the middle) such as

place [sprite] on top of (tilemap col( (tilemap.columns % 2 )) row (tilemap.rows - 1))

Are you talking about placing a Sprite onto one of those (col, row) coordinates?

This is the tilemap row and column where you can edit the space on how big you want the tilemap to be.

1 Like

Exactly. I need to remember those values for each tilemap I make, and maybe even store that in a variable. I want to be able to call block code to get those values, so that if I change the tilemap, the, code such as:

let centerX = tilemap.width / 2
let centerY = tilemap.height / 2

Still works.

So you want to turn this as a function and still call those numbers?

You know like this?

You can always change the numbers on the function so you don’t have to remember as much number I think

1 Like

I think @cosmoscowboy wants to be able to get the width and height from his code, and not need to hard code the tilemap with and height in his code

1 Like

oh. I was just trying to help

1 Like

I like your idea of creating the function, but it is just the same as having called the original code of ‘place sprite on top of…’.

I am just curious to know if you can get the width/height of a tilemap in order to make decisions in code based on those values. Thanks for your help.

You’ll want to use the tilemaps extension for that:


Under the location group:



@jwunderl Thanks, I indeed came across that extension, it is very helpful.