Using "For Each" correctly

0 favourites
  • 3 posts
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • Hi, I made a random dungeon generator seen here:

    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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • Ethan

    Solved it. Thank you.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)