TileMap, detect all whitespace and create various objects

0 favourites
  • 3 posts
From the Asset Store
Human/Character Base Pixel Art Sprites in various poses (nearly 100 files)
  • Hi guys, I searched here in the topics about my question and I didn't find it, and the following ones I created a system to change the size of the Tilemap through the touch and then when I release the screen button then it creates several objects in the width and height using loopindex , only this tilemap will be erasable when I tap on it so a block is erased at the place I clicked, and then I save the json of the tilemap with the filled blocks and the various ones in the array, I want it when I open the game again automatically detect the filled blocks and the several and then just create the objects in the blocks that are filled and the several remain several until I create objects over them again

    what am I doing wrong ?

    + System: for "X" to 0 a Tile.width/Tile.width

    + System: for "y" to 0 a Tile.height/Tile.height

    + Tile: tile (loopindex("x"), loopindex("y")) # -1

    -> System: [Create object coin on layer "Tile" at (Tile.PositionTileX(loopindex("x")), Tile.PositionTileY(loopindex("y"))), create hierarchy: no, template: ""]

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • For the first loop, you need to divide the TileMap.Width by Tile Size and the same for the Height

    Example:

    We have a Tilemap that has (Tile size =32)

    For "Y" From 0 To floor(Tilemap.Height/32) -1
    ------For "X" From 0 To floor(Tilemap.Width/32) -1
    
    + Tile.At(loopindex("X"), loopindex("Y")) # -1
    
    
    -> System: [Create object coin on layer "Tile" at
    
    Tilemap.TileToPositionX(Loopindex("X"))
    Tilemap.TileToPositionY(Loopindex("Y"))
    
    
    
  • For the first loop, you need to divide the TileMap.Width by Tile Size and the same for the Height

    Example:

    We have a Tilemap that has (Tile size =32)

    > 
    For "Y" From 0 To floor(Tilemap.Height/32) -1
    ------For "X" From 0 To floor(Tilemap.Width/32) -1
    
    + Tile.At(loopindex("X"), loopindex("Y")) # -1
    
    
    -> System: [Create object coin on layer "Tile" at
    > 
    > Tilemap.TileToPositionX(Loopindex("X"))
    > Tilemap.TileToPositionY(Loopindex("Y"))
    > 
    > 
    > 

    Thanks for helping me, I did what you suggested and it goes through the entire tilemap in the loopindex but it ends up creating several coins overlapping the other and sometimes some tile that I deleted is filled and others not

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