• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code GMS2 draw_tile trouble

B

bretseattle

Guest
Tile error.png I am having trouble getting the draw_tile function to work, below is my code. Basically the tiles are drawn but about 20 pixels along the x axis they are cut off, I colored the background and it looked like that was what was blocking the sprites but but when I removed the background from the layers there was still a black boundary obscuring the sprite layer. I have tried playing with the depth of layers bringing it forward and back but the screen is always the same. I have only one sprite, tileset and Screenshot (2).png game object that runs this code and haven't created anything else in this build. Is this a bug or just something really simple that I am missing?
Below is the code

layer_id = layer_create(-400);

layer_tilemap_create(layer_id, 0, 0, tileset_ground, 10, 10)

var tiledata = 3

draw_tile(tileset_ground, tiledata, 0, 16, 34);

var tiledata = 2

draw_tile(tileset_ground, tiledata, 0, 0, 0);

draw_tile(tileset_ground, tiledata, 0, room_width -32, 0);
 

Attachments

Nocturne

Friendly Tyrant
Forum Staff
Admin
layer_id = layer_create(-400);

Do you have that in the draw event? If so then it's creating a new layer every step, which is a no-no.... also WHICH draw event are you performing this in? Oh, and if you are only drawing the tiles, then there is no need for the tile layer or the tilemap... you can draw tiles anywhere, but if you add them to a layer they will be drawn automatically as part of the layer render.
 
B

bretseattle

Guest
Thank you very much, I was not running the code in the draw event
 
Top