Add ability to mark tiles or layers as property only

I need the ability to mark tiles or layers as property only so that mte does not create a display object for tiles that are only present for configuration purposes.

Why?

I have found that when creating huge maps it is desirable to create tilesets that exist only to adorn a tile with a set of properties.  This is to get around the cumbersome property editing in Tiled.

Using tilesets in this way is great when working in tiled as we also get a visual representation of properties that are assigned to a given location.   We can also mix and match configurations by creating additional tilesets and painting the tiles on additional layers.

What I am doing now is simply making the layer that has my “property only” tiles invisible but what would be great is if the visual display object for these tiles was not even created in the first place.  

in my game it is creating 300+ unneeded display objects. 

is a quick fix is possible?

Best,

Steven

I’m always impressed by other developer’s abilities to find new function uses I hadn’t anticipated. I can see why this would be useful! Objects created in Tiled are just nondescript grey boxes, while tiles are immediately identifiable.

Should be easy enough to put in, I’ll do that today.

A new update is coming next week. After that I’ll be starting the optimization rewrite.

I have to admit I’m impressed too. It’s rather ingenius, almost like the old school palette swapping to save graphics memory!

I hadn’t thought of using this but it certainly sounds like something i’ll try in the future.

I’ve added a noDraw property. You can set this property on tiles, layers, and tilesets with predictable results. Though the display object is not created, a table containing the tile properties is created. Calling getTileObj will return a table containing properties rather than a display object containing parameters. The property listener function will work as normal with non-drawn tiles as well.

Great Stuff!  :smiley:

Hey Steven,

I was hoping you might be able to share some of your logic here for me.

I’m hoping to have tiles have a range of default properties when initially starting my game; however the only way I can see to do this so far is assigning the properties to each tile in the tileset? 

Is this the best way forward; I imagine you’re suggesting a better way but I can’t quite visualise it.

Many thanks,

Chris

Edit:

To add to this description, I need each tile to act independently with these properties - however the properties will be the same for each tile. I was thinking I could just assign it as a layer property, but obviously that wouldn’t allow me to have each tile acting on its own.

the method that i describe involves creating a tileset whose only role is to provide properties for a set of cells on a map.

this is useful for properties that are not tied to a cells view.

in my game I create a 4 by 4 tileset with each tile having a visual representation of the properties it contains.

Take the case of spawn locations, each tile in my spawn_locations tileset presents a view that is representative of the NPC type I would like to spawn. in photoshop i create the tileset with each having a unique label “npc 1”, “npc 2”, “npc 3” etc.

In tiled I edit each tile in my spawn_locations tileset to include a property called  npc_type. for the tile representing npc 1: its npc_type property  equals  1.

Now I create a separate layer in tiled. Its job is to hold configuration tiles from my spawn_locations tileset. I don’t want these tiles visible outside of tiled but I want to be able to see them in tiled so that I can visualise the map layout. i.e which entities are spawning from where.

When the map is loaded by mte i now use the noDraw property to ensure that display objects are not created for the tiles placed in the map originating from the  spawn_locations tileset.

Although these tiles are not drawn I can still query the cell, and get a list of properties defined in it. including those from the invisible spawn_locations tileset/layer.

the same can be achieved with tiled objects  but with objects you don’t get the benefit of being able to see unique properties on a tile without opening the properties dialog.

on a separate layer/layers I place tiles that I want to represent the visual aspect of the map like grass tiles or road tiles. these tiles can have their own generic properties (i.e for grass tiles you may want to put an identifier so you know that the player is walking on grass … etc etc). Obviously this tying of view to property is not great for spawn locations as not every grass tile is a spawn location. Plus I may want spawn locations on road tiles or bridge tiles… ad googleplexion :wink:

Thanks for the info - I’ve just realised the futility of my approach however.

Saving properties to the tile will mean that . Essentially I have 3 layers representing water, dirt, grass and I need to store properties such as water level, nutrient level, etc… on each cell - each cell needs to act independently of one another.

So I don’t think this approach will work - I think I may need to work outside of MTE/Tiled for the solution.

I briefly considered changing map.layers[layer].world[locX][locY] into an array for storing the tileID, the tile object, and so developers could add additional parameters. This proved to add another 50% to map load times, so I’ve shelved the idea for now.

What you can do is get the map table with mte.getMap() and add your own two-dimensional array to it for storing your cell -by -cell data. As part of the map table your array would be saved and loaded with the rest of the map.

I’m always impressed by other developer’s abilities to find new function uses I hadn’t anticipated. I can see why this would be useful! Objects created in Tiled are just nondescript grey boxes, while tiles are immediately identifiable.

Should be easy enough to put in, I’ll do that today.

A new update is coming next week. After that I’ll be starting the optimization rewrite.

I have to admit I’m impressed too. It’s rather ingenius, almost like the old school palette swapping to save graphics memory!

I hadn’t thought of using this but it certainly sounds like something i’ll try in the future.

I’ve added a noDraw property. You can set this property on tiles, layers, and tilesets with predictable results. Though the display object is not created, a table containing the tile properties is created. Calling getTileObj will return a table containing properties rather than a display object containing parameters. The property listener function will work as normal with non-drawn tiles as well.

Great Stuff!  :smiley:

Ive been using this same approach for a while now but I like your idea about having a noDraw property! This will speed up my game quite a bit. I just need to wait until after final exams get over.

Hey Steven,

I was hoping you might be able to share some of your logic here for me.

I’m hoping to have tiles have a range of default properties when initially starting my game; however the only way I can see to do this so far is assigning the properties to each tile in the tileset? 

Is this the best way forward; I imagine you’re suggesting a better way but I can’t quite visualise it.

Many thanks,

Chris

Edit:

To add to this description, I need each tile to act independently with these properties - however the properties will be the same for each tile. I was thinking I could just assign it as a layer property, but obviously that wouldn’t allow me to have each tile acting on its own.

the method that i describe involves creating a tileset whose only role is to provide properties for a set of cells on a map.

this is useful for properties that are not tied to a cells view.

in my game I create a 4 by 4 tileset with each tile having a visual representation of the properties it contains.

Take the case of spawn locations, each tile in my spawn_locations tileset presents a view that is representative of the NPC type I would like to spawn. in photoshop i create the tileset with each having a unique label “npc 1”, “npc 2”, “npc 3” etc.

In tiled I edit each tile in my spawn_locations tileset to include a property called  npc_type. for the tile representing npc 1: its npc_type property  equals  1.

Now I create a separate layer in tiled. Its job is to hold configuration tiles from my spawn_locations tileset. I don’t want these tiles visible outside of tiled but I want to be able to see them in tiled so that I can visualise the map layout. i.e which entities are spawning from where.

When the map is loaded by mte i now use the noDraw property to ensure that display objects are not created for the tiles placed in the map originating from the  spawn_locations tileset.

Although these tiles are not drawn I can still query the cell, and get a list of properties defined in it. including those from the invisible spawn_locations tileset/layer.

the same can be achieved with tiled objects  but with objects you don’t get the benefit of being able to see unique properties on a tile without opening the properties dialog.

on a separate layer/layers I place tiles that I want to represent the visual aspect of the map like grass tiles or road tiles. these tiles can have their own generic properties (i.e for grass tiles you may want to put an identifier so you know that the player is walking on grass … etc etc). Obviously this tying of view to property is not great for spawn locations as not every grass tile is a spawn location. Plus I may want spawn locations on road tiles or bridge tiles… ad googleplexion :wink:

Thanks for the info - I’ve just realised the futility of my approach however.

Saving properties to the tile will mean that . Essentially I have 3 layers representing water, dirt, grass and I need to store properties such as water level, nutrient level, etc… on each cell - each cell needs to act independently of one another.

So I don’t think this approach will work - I think I may need to work outside of MTE/Tiled for the solution.

I briefly considered changing map.layers[layer].world[locX][locY] into an array for storing the tileID, the tile object, and so developers could add additional parameters. This proved to add another 50% to map load times, so I’ve shelved the idea for now.

What you can do is get the map table with mte.getMap() and add your own two-dimensional array to it for storing your cell -by -cell data. As part of the map table your array would be saved and loaded with the rest of the map.

Ive been using this same approach for a while now but I like your idea about having a noDraw property! This will speed up my game quite a bit. I just need to wait until after final exams get over.