Erase tile by tile number and create object in it's place

Discussion and feedback on Construct 2

Post » Fri Sep 22, 2017 11:56 pm

I'm making an arcade style game where at the beginning of each level ajax loads a randomly selected tilemap.
The tilemap has nine different images.
I want to find a way to delete each tile that uses the ninth tile from the tilemap image and destroys that tile, then creates an object at the place the tile was destroyed.

When I go into the tilemap editor to edit the image of a tile I see that the ninth tile is labeled as "Tile 8" (Probably because of the 0 index values) but I have no idea how to access this info via an event.

Ideally it would be good to have a condition that picks all tiles using "Tile 8" and replaces them.
B
7
S
1
G
1
Posts: 7
Reputation: 889

Post » Sat Sep 23, 2017 12:21 pm

Are your layouts the same size? If they are, I probably have a solution of how to do it, otherwise it might get slightly more complicated.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
53
S
24
G
30
Posts: 543
Reputation: 19,691

Post » Sat Sep 23, 2017 2:59 pm

LaDestitute wrote:Are your layouts the same size? If they are, I probably have a solution of how to do it, otherwise it might get slightly more complicated.


Yes! In fact the goal of the game is to all take place on the same layout with only the tilemap and objects switching out mid gameplay.
B
7
S
1
G
1
Posts: 7
Reputation: 889

Post » Sat Sep 23, 2017 7:43 pm

You should make two global variables. One for the tile's X and one for the tile's Y.

Set variableX to: TileMapName.PositionToTileX()
Set VariableY to: TileMapName.PositionToTileY()

Set the layout position into the (), i.e as an example number for PositionToTileX(24). Then, using the Erase Tile action under your tilemap, set the X/Y when it asks for them to your global variables and you can then also use your two global variables to spawn in an object at the same location right after, as long as you don't overwrite or erase what is in your two global variables.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
53
S
24
G
30
Posts: 543
Reputation: 19,691

Post » Sat Sep 23, 2017 11:24 pm

LaDestitute wrote:You should make two global variables. One for the tile's X and one for the tile's Y.

Set variableX to: TileMapName.PositionToTileX()
Set VariableY to: TileMapName.PositionToTileY()

Set the layout position into the (), i.e as an example number for PositionToTileX(24). Then, using the Erase Tile action under your tilemap, set the X/Y when it asks for them to your global variables and you can then also use your two global variables to spawn in an object at the same location right after, as long as you don't overwrite or erase what is in your two global variables.


Thanks you so much! Looks like I got it working.
B
7
S
1
G
1
Posts: 7
Reputation: 889


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 5 guests