fulade's Forum Posts

  • 4 posts
  • Update:

    Finally, I saw some Light and understood why is working the (Tilemap.TileToPositionX(loopindex("Y")))

    It's because your Map it's perfectly aligned on the Grid and the Origin Point of the TileMap (0,0) also the Tiles are symmetric 64x64

    So even that the true it Loops Retrieving the X-Coordinates Of the Tiles using the Index of Loopindex("Y") but because the Tiles are symmetric and Both Indexes start at 32

    Example:

    (Tilemap.TileToPositionX(loopindex("Y=0"))) >>>>> 32px at the X Cordinates

    (Tilemap.TileToPositionX(loopindex("Y=1"))) >>>>> 96px at the X Cordinates

    (Tilemap.TileToPositionX(loopindex("Y=2"))) >>>>> 160px at the X Cordinates

    (Tilemap.TileToPositionX(loopindex("Y=3"))) >>>>> 224px at the X Cordinates

    Etc.....

    Will be the same as if you used TileToPositionY

    (Tilemap.TileToPositionY(loopindex("Y=0"))) >>>>> 32px at the Y Cordinates

    (Tilemap.TileToPositionY(loopindex("Y=1"))) >>>>> 96px at the Y Cordinates

    (Tilemap.TileToPositionY(loopindex("Y=2"))) >>>>> 160px at the Y Cordinates

    (Tilemap.TileToPositionY(loopindex("Y=3"))) >>>>> 224px at the Y Cordinates

    Etc...

    This Time you been Lucky as the TileMap was aligned to the Grid :)

    But if the TileMap wasn't Aligned to the Grid Example:

    TileMap Position at (250, 92)

    and the First Tile Coordinates will be at (X=282, Y=124)

    So if you use the same System as you did to Retrieve the Y-Coordinates

    (Tilemap.TileToPositionX(loopindex("Y=0"))) >>>>> 282 px at the X Cordinates (Wrong)

    Vs

    (Tilemap.TileToPositionY(loopindex("Y=0"))) >>>>> 124 px at the Y Cordinates (Correct)

    as you can see the Results can be very very wrong, Conclusion the sooner you start using the correct expressions the fewer mistakes and headache you will have in the future, even if it did work this Time swapping the Loopindexs is not guarantee it will work next Time, but if you use always the correct Expressions you will have peace

    Wow, you`re a real nutcracker. At the moment this is the best solution for me to create a path on a tilemap.

  • > Thanks for the push into array hint, it helped me, man. The only moment is I had to use push forward instead of push back, but anyway I`m satisfied with the result, though I am not quite sure about how it works, to my shame.

    >

    No Problem mate,

    Are you sure that is working Properly?

    -Because after you Push you are using (Array.CurX) which is meant to work only with Array "For Each

    Element" if you use Push Front you can use Directly ArrayX = 0 probably that's why it worked for you as you don't use the "For Each Element" so when you use Array.CurX it will be always at = 0

    -Edited

    -And also you are storing Twice (TileToPositionX) Instead of Y

    My intention was to make a path for an object step by step which begin from ID0 tile and continue along ID1, ID2, ID3, ID4 etc.

    See my new capx with a path and an object: dropbox.com/s/vq1ikzdwyfgfsek/waypointsTest2.capx

    It`s moving as it supposed to, even if I`m using (TileToPositionX) twice, actually if I change the second one to (TileToPositionY) nothing changes, atm I don`t have time to dig it, maybe in the future if it will cause a bug :-)

  • You are Looping throughout the Whole TileMap Which has 20x20 = 400 Tiles but your Array size its only 10x3

    also, it's not very clear how you trying to save you Logic as to save on the exact coordinates that match the TileMap you need to use 2D Coordinates Example Array.At(X,Y)

    then save the (TileID, X Coordinates, Y Coordinates) on the same Array Location separated by commas

    Or

    If you don't really need to match the Array.At(X,Y) to the TileMap Tile(X,Y) then you can set the Array Size at the start of the layout to Size = (Width =0, Height =3)

    Then Push Back on the X = Tilemap.TileAt(loopindex("x"), loopindex("y"))

    Then Set (Same X, 1) = Tilemap.TileToPositionX(loopindex("x"))

    Then Set (Same X, 2) = Tilemap.TileToPositionY(loopindex("y"))

    Like you were attempting to do, so you End up with

    Array X all the Tiles Number

    Array Y = 1 >>>All the X Positions

    Array Y = 2 >>>All the Y Positions

    Thanks for the push into array hint, it helped me, man. The only moment is I had to use push forward instead of push back, but anyway I`m satisfied with the result, though I am not quite sure about how it works, to my shame.

    Edited:

    Result:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi all,

    I`m trying to locate all non-empty tiles on a tilemap and insert their ID, X (in pixels) and Y (in pixels) into an array, but not all of the tiles data appear in the array (red frame on the screenshot below).

    I log the same data in browser console and everything is ok (green frame on the screenshot below).

    Please share your ideas on how to fix this. Thnx!

    Dropbox link to my capx file: https://www.dropbox.com/s/jxuhx6p7ma1sewo/waypointsTest.capx?dl=0

    Tagged:

  • 4 posts