How do I Select tiles from another tilemap

Get help using Construct 2

Post » Mon Jun 22, 2015 11:10 am

Image

I have 2 tilemap. One called Main Tile and another one called Ore Tile. How can i select a the tiles from Ore Tile while i work with the Main Tile? Or do i need to combine all the tilemaps into one tile?
B
4
S
1
Posts: 11
Reputation: 372

Post » Mon Jun 22, 2015 11:18 am

I'm not sure what you are trying to do here, but if you want to set a tile of the ore tile, you should use ore tile set tile..

You can call the tiles from ore tile through the expressions like you use for maintile in the above example..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jun 22, 2015 11:52 am

Its a bit difficult to see what you are trying to do, but assume you want to use one tile map to spawn/change something on the other?

You have to set up some condition for the Ore tile map and then change it for the Main tile. Here is a simple example:

It uses two tile maps, one with orange boxes and one with green boxes. Based on where the orange boxes are placed I want to place green boxes on the right side of them.

Image

So the code:
Image

Using two loops to go through tile map 1, dividing the width and height with 50, because that's the size of the tiles will give me the tile index coordinate of the tile maps.

Then checking whether the giving tile on tile map 1 = 0 and if that's the case I set the tile right of the selected tile on tile map 2 to a green square.

Image

You only really need to use positionToTile when you try to place a none tile map object, like a sprite on a tile map or if you want to track mouse position etc.

If what you are trying is to get a random tile from your Ore map and use it for your main tile map.

You just have to get the tile index using the same method I used above.

Tilemap.width / Tile.width
Tilemap.height / Tile.height

And if you need to randomize it
Random(Tilemap.width / Tile.width) etc.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Tue Jun 23, 2015 12:52 pm

nimos100 wrote:Its a bit difficult to see what you are trying to do, but assume you want to use one tile map to spawn/change something on the other?

You have to set up some condition for the Ore tile map and then change it for the Main tile. Here is a simple example:

It uses two tile maps, one with orange boxes and one with green boxes. Based on where the orange boxes are placed I want to place green boxes on the right side of them.

Image

So the code:
Image

Using two loops to go through tile map 1, dividing the width and height with 50, because that's the size of the tiles will give me the tile index coordinate of the tile maps.

Then checking whether the giving tile on tile map 1 = 0 and if that's the case I set the tile right of the selected tile on tile map 2 to a green square.

Image

You only really need to use positionToTile when you try to place a none tile map object, like a sprite on a tile map or if you want to track mouse position etc.

If what you are trying is to get a random tile from your Ore map and use it for your main tile map.

You just have to get the tile index using the same method I used above.

Tilemap.width / Tile.width
Tilemap.height / Tile.height

And if you need to randomize it
Random(Tilemap.width / Tile.width) etc.


What i mean is how to set a tile from another tile set..
B
4
S
1
Posts: 11
Reputation: 372

Post » Tue Jun 23, 2015 12:54 pm

LittleStain wrote:I'm not sure what you are trying to do here, but if you want to set a tile of the ore tile, you should use ore tile set tile..

You can call the tiles from ore tile through the expressions like you use for maintile in the above example..


Yes im looking for the expression and still no clue.. helpp
B
4
S
1
Posts: 11
Reputation: 372

Post » Tue Jun 23, 2015 1:07 pm

Kevinyobeth wrote:
LittleStain wrote:I'm not sure what you are trying to do here, but if you want to set a tile of the ore tile, you should use ore tile set tile..

You can call the tiles from ore tile through the expressions like you use for maintile in the above example..


Yes im looking for the expression and still no clue.. helpp


I would gladly help you if I could only understand your question..

You do understand that each tilemap can only contain its own tiles, right?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Jun 23, 2015 1:23 pm

Kevinyobeth wrote:What i mean is how to set a tile from another tile set..

As littlestain says, each tile map are an its own object you can't copy a single tile (Graphic) from one to another, if that is what you are trying to do? What you can do is load another tile map when you need to, but it would be a bad approach I think compared to just adding the needed tiles to the map or simply let tiles from Ore map overwrite those on the main tile map.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,848

Post » Tue Jun 23, 2015 3:32 pm

LittleStain wrote:
Kevinyobeth wrote:
LittleStain wrote:I'm not sure what you are trying to do here, but if you want to set a tile of the ore tile, you should use ore tile set tile..

You can call the tiles from ore tile through the expressions like you use for maintile in the above example..


Yes im looking for the expression and still no clue.. helpp


I would gladly help you if I could only understand your question..

You do understand that each tilemap can only contain its own tiles, right?


Nevermind i decided to combine both the tile map into a single tile map. Thanks
B
4
S
1
Posts: 11
Reputation: 372


Return to How do I....?

Who is online

Users browsing this forum: Darknessed and 43 guests