• 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.

 tileset_get_sprite_index (suggestion)

P

Peter Verbeek

Guest
For my game I need a function tileset_get_sprite_index(tileset_Index) to retrieve the sprite index of the tileset of the current set tilemap on a layer. I may not use layer_tile_get_sprite because it's a compatibility function. I can use the draw_tile function but I need to scale it up. Besides, are there any functions solely related to a tileset (tileset_get_*) ?

Game mechanics in depth: After creating a new room during game time the layers are created. One layer is the tiles layer and the room (level) type determines the tileset used on this layer. In other words each in game created room has a specific tileset. I want to show on the gui one or more tiles of the room specific tileset during game time. Therefor I need the sprite index to draw a tile as part of the tileset sprite. This drawing has to be scaled up because the tiles are to small for the gui.

Thanks
 

Perseus

Not Medusa
Forum Staff
Moderator
Doesn't tilemap_get_tileset already return the index of the tileset used in a tilemap? As for scaling the tiles, draw them onto a surface via draw_tile, then use draw_surface_ext to draw the surface scaled up in the Draw GUI event.
 
P

Peter Verbeek

Guest
Yes, tilemap_get_tileset does return the index and with this index I should access the sprite using tileset_get_sprite_index, for example:

draw_sprite_part_ext(tileset_get_sprite_index(tilemap_get_tileset(layer_tilemap_get_id(layer_get_id("Tiles")))), etc.​

or even nicer:

draw_tileset_tile_ext(tilemap_get_tileset(layer_tilemap_get_id(layer_get_id("Tiles"))),20,2,2,c_white,1) where 20 is the 20th tile, drawn at scale 2
But your suggestion does do the job. Thanks. Surfaces are always a good way to go. Why didn't I think of it?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
This possibly can't be done due to the fact that you can flag a Tileset as NOT exporting the accompanying sprite resource. So you would essentially be looking for a sprite that doesn't exist.
 
P

Peter Verbeek

Guest
In GM 2.05.72 there's a posibility to export the sprite in the tileset properties so it does work. I'm able to draw (a part of) the tileset sprite by unchecking the Disable source sprite export checkbox :)
 

rwkay

GameMaker Staff
GameMaker Dev.
Ok can I point out to you that doing that means the data is stored twice as the sprite for a tileset and the tileset graphic itself are 2 different things, we have to modify the tileset graphic (based on the original sprite) to add gap information that allows seamless tiling on GPU hardware - this means you are using slightly more than twice the space so you can display the sprite too...

This is fine if that is what you want / need but you should be aware of it.

Russell
 
P

Peter Verbeek

Guest
Thanks Russell for your reply.

If I do things the "old" way so creating additional sprites for each specific tile I also end up with additional space. Besides changing a tile on the tileset sprite means changing the corresponding (second) sprite tile.
 
Top