With this function you can assign a tileset resource to a layer to be used as a tilemap in your project. You supply the layer ID (which you get when you create the layer using layer_create()) or the layer name (as a string - this will have a performance impact) and then an initial (x, y) position to add the tilemap to the room, the tile set resource to use, and then the width and height of the tilemap in cells (ie: a width of 20 and a height of 10 will create a tilemap with 200 cells that is 20 cells wide and 10 cells tall), with the size of the cells themselves being defined by the tile set chosen. It is worth noting that you cannot place tiles at negative positions within the tilemap, so all tiles must be placed within the cell spaces 0 to width, 0 to height.
layer_tilemap_create(layer_id, x, y, tile set, width, height)
参数 描述 layer_id The unique ID value of the layer to target (or the layer name as a string) x The x position of the tilemap in the room y The y position of the tilemap in the room tile set The tile set index to be used 宽度 The width tilemap (in cells) 高度 The height of the tilemap (in cells)
tilemap element ID (Real)
global.back_layer = layer_create(10000);
global.back_tiles = layer_tilemap_create(global.back_layer, 0, 0,
tmap_Trees, 16, 32);
The above code creates a new layer and then adds a new tilemap element to it, setting the tilemap position to (0,0) as well as the tile set to be used and the width and height of the tilemap.