Page 48 of 92

Re: Simple Tiled Implementation - STI v0.14.1.13

Posted: Tue May 31, 2016 9:53 am
by bobbyjones
Karai17 wrote:You need to use math.floor to make sure you are translating and drawing to an internet value.
Integer value I think you mean.

Re: Simple Tiled Implementation - STI v0.14.1.13

Posted: Tue May 31, 2016 12:35 pm
by Karai17
Mobile phones tho

Re: Simple Tiled Implementation - STI v0.14.1.13

Posted: Tue May 31, 2016 10:02 pm
by rod_sn
quick question, how can i, for example, make a door, or other interactive object on the map? Or how can i change the tile image for a tile that was inserted on an object layer? ty :3

edit: actually is there any way i can even update the proprieties of the layer/object layer?

Re: Simple Tiled Implementation - STI v0.14.1.13

Posted: Wed Jun 01, 2016 1:30 am
by Karai17
If you use the Box2D plugin, you can create a sensor object that performs some action when you collide with it. Set the properties collidable = true and sensor = true. If you use a different plugin, or your own collision code, you can code that in manually.

You can swap out a tile using Map:swapTile(current_tile_instance, new_tile_object)

Re: Simple Tiled Implementation - STI v0.14.1.13

Posted: Wed Jun 01, 2016 2:01 am
by rod_sn
ok thanks. So i cant change a propriety of a tile while running the program?
Edit: this is because i tried to change it while running, and it wont update... I added the map:update(), so idk why it wont change.

Re: Simple Tiled Implementation - STI v0.14.1.13

Posted: Wed Jun 01, 2016 2:06 am
by Karai17
Yes and no. You can't change the properties of an individual instance of a tile, but you can change the properties of a tile, and all of its instances. Map.tiles[gid].properties is what you're after.

Re: Simple Tiled Implementation - STI v0.14.1.13

Posted: Wed Jun 01, 2016 2:16 am
by rod_sn
but if i have multiple doors, and i only want one to open, i cant use the way you told me now, it would change the properties of all the doors using that tile, no?

Re: Simple Tiled Implementation - STI v0.14.1.13

Posted: Wed Jun 01, 2016 2:19 am
by Karai17
You don't want to use tiles for such things. Use tile objects in Tiled to place individual door objects, and then update them individually in love.

Re: Simple Tiled Implementation - STI v0.14.1.13

Posted: Wed Jun 01, 2016 2:45 am
by rod_sn
update them with Map.tiles[gid].properties?
or with swap? im so confused ;-;

Re: Simple Tiled Implementation - STI v0.14.1.13

Posted: Wed Jun 01, 2016 2:47 am
by Karai17
Map:swapTile is used to replace a tile in a layer with a different one. Map.tiles[gid] is a tile object that you can modify so that all tile instances will be updated (exept for the graphic, you need to use swapTile for that since sprite batching acts like a cache).