Using "For Each" correctly

Get help using Construct 2

Post » Mon Apr 18, 2016 2:23 pm

Hi, I made a random dungeon generator seen here:

Image

Every black square is a 16x16 sprite. I'm using a For Each loop to turn every square into a spot on the corresponding tilemap then to destroy the sprite, but the tiles don't show up anywhere.

My event is like this: For Each Sprite > Tilemap Set Tile (Sprite.X*16, Sprite.Y*16) to tile 210 (normal)

(I put the *16 in there so they would match the 16x16 tilemap as seen in my previous post. The reply stated: "For ex, a sprite at 10,10 corresponds to a tile in position 160,160 (10 * 16)")

If that's tilemap thing is wrong, then how would you do it?

With my main question, how do you make the Sprite.(X,Y) update to the next Sprite after the first one is set to the tile and destroyed?

Thanks.
B
8
S
2
Posts: 15
Reputation: 530

Post » Mon Apr 18, 2016 3:34 pm

Tile maps use grid coordinates 0,1,2,3 etc. You need to convert the layout x and y positions of the sprite into grid coordinates first so the tile map knows which tile to select. There is an expression for doing it in the tile map object.
B
43
S
23
G
20
Posts: 735
Reputation: 12,027

Post » Mon Apr 18, 2016 3:50 pm

@Ethan

Solved it. Thank you.
B
8
S
2
Posts: 15
Reputation: 530


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 14 guests