Erase all tiles from tile, except for tiles specified?

Get help using Construct 2

Post » Wed Mar 01, 2017 10:59 am

Is there a way of clearing ALL of the tiles from a tilemap, except for specific tiles listed in a variable? I'm using @r0j0hound 's example: https://dl.dropboxusercontent.com/u/542 ... lemap.capx but in my situation, it would be much more efficient to clear all of the tiles, besides the few I need, rather than clear a selected few. I thought I'd start a new thread as the last tilemap thread got a bit away from the original point.
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Wed Mar 01, 2017 7:04 pm

Changed the title to be more descriptive.
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Wed Mar 01, 2017 7:18 pm

You should be able to do it by changing the logic around. In it able to open the capx right now so this may be a bit different. You don't even need a variable. You could take a loop over all the tiles and make these sub-events to keep for example tiles 4 and 6.

Tile=4

Else
Tile=6

Else
--- erase


Or if you still wish to use a variable just structure the text variable used for the list like this. Comma seperated and starting and ending with a comma.

Global text keep=",4,6,"

Then use a sub-event like this:

System compare: find(keep, ","&tile&",") = -1
--- erase
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Wed Mar 01, 2017 7:26 pm

R0J0hound wrote:You should be able to do it by changing the logic around. In it able to open the capx right now so this may be a bit different. You don't even need a variable. You could take a loop over all the tiles and make these sub-events to keep for example tiles 4 and 6.

Tile=4

Else
Tile=6

Else
--- erase


Or if you still wish to use a variable just structure the text variable used for the list like this. Comma seperated and starting and ending with a comma.

Global text keep=",4,6,"

Then use a sub-event like this:

System compare: find(keep, ","&tile&",") = -1
--- erase

Thanks! Here's a screencap of what I have so far, it WORKS, it's just going to be inefficient when I fill up those tiles:
Image
I'll try and use your suggestion, I'm not sure if the screengrab is of any use to you. I have three tilemaps, one for display, one for solids and one for jump-thrus.
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Wed Mar 01, 2017 7:38 pm

@r0j0hound trying to work out what &tile& should be?
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Wed Mar 01, 2017 7:44 pm

Replace tile with the expression to get a tile at a location.
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Wed Mar 01, 2017 9:47 pm

EDIT: This works!
Image
Thank you @r0j0hound! Hopefully that looks okay?
Last edited by Zebbi on Wed Mar 01, 2017 10:18 pm, edited 2 times in total.
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253

Post » Wed Mar 01, 2017 10:08 pm

TileAt(loopindex("x"),loopindex("y"))
B
91
S
31
G
102
Posts: 5,232
Reputation: 67,250

Post » Wed Mar 01, 2017 10:19 pm

R0J0hound wrote:TileAt(loopindex("x"),loopindex("y"))

Sorry, got it myself in the end! :oops:
Image
B
41
S
12
G
14
Posts: 1,117
Reputation: 11,253


Return to How do I....?

Who is online

Users browsing this forum: Clark Thy Lord and 1 guest