Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
Using Tiled - Page 2 — Gideros Forum

Using Tiled

2»

Comments

  • Ah, thanks -I just examined a .lua map as exported from Tiled and figured it out. So gid is a tile's unique id number across all the tilesets used.

    But there are still many questions:

    1. What is a Gideros TileMap exactly? A group containing bitmaps?

    2. If so, can we access the individual tiles using :getChildAt()? Using what index then?

    3. Can we update / swap / remove / tint individual tiles?

    4. If we have multiple map layers, should we create one TileMap for each layer?

    5. Can we create an "endless scrolling" maps using TileMap? Imagine a car that drives on a horizontally scrolling map. When the end of the map is reached, is it possible to seemlessly draw the tiles from the beginning of the map again to achieve the impression of an "infinite" scrolling map?

  • ar2rsawseenar2rsawseen Maintainer
    edited September 2013
    1. you can interpret TileMap as one large Bitmap, with separate texture regions, basically it is a single object like Bitmap or Sprite, without any additional children

    2. You can set each specific tile using TileMap:setTile method, and provide x, y position in TileMap object (starting from 1, as in 1;1 would be first row, first column) and provide an image to set from tileset (texture provided in the constructor) using similar indexes of tile image in the tile set (1;1 would be first row, first column in the provided texture of tile set)
    http://docs.giderosmobile.com/reference/gideros/TileMap/setTile#TileMap:setTile

    3) you can replace the texture of the tile the same way described in the setTile method. Additionally you can clear specific tile using clearTile and providing same Tile indexes
    http://docs.giderosmobile.com/reference/gideros/TileMap/clearTile#TileMap:clearTile

    Also when setting a tile you may provide 5th optional argument to flip the specific tile
    TileMap.FLIP_DIAGONAL
    TileMap.FLIP_HORIZONTAL
    TileMap.FLIP_VERTICAL

    4. yes exactly. there should be separate TileMap object for each layer

    5. You can dynamically shift the tiles using shift method, although I did not experiment with it and @atilim would probably know better, but I think shifting, does not loop the tiles, as in, the tiles you shifted from will not appear on the other end (but I might be mistaken), but you can again reassign them on each shift using setTile method always applying to the last row or column (depending on direction of scroller).
    http://docs.giderosmobile.com/reference/gideros/TileMap/shift#TileMap:shift

    Here are more on TileMap:
    http://docs.giderosmobile.com/reference/gideros/TileMap#TileMap
    http://www.giderosmobile.com/forum/discussion/comment/6998

    ;)

    Likes: neverjoy

    +1 -1 (+1 / -0 )Share on Facebook
  • MauMauMauMau Member
    edited September 2013
    Thanks ar2rsawseen. I already read the docs but they are of no help. The explanation of the parameters is just too vague (as with many other Gideros commands explained there). I really hope the docs would be improved -more in-depth explanations, explaining what it does behind the scenes, hints, sample codes etc., not just ultra-short, ambivalent explanations of a method's parameters.

    For example:

    Description:
    Sets the index of the tile. The tile indices are starting from 1.

    TileMap:setTile(x, y, tx, ty, flip)
    x: (number) The x-position of tile
    y: (number) The y-position of tile
    tx: (number) The x-index of the tile
    ty: (number) The y-index of the tile

    - What does it mean with "index of a tile". Probably the "unique tile id"?
    - x: What means "x-position"? A pixel value? Or a column value on the map?
    - And what is an "x-index"?

    When referring to tile maps, you usually use the terms column (x-position on the map), row (y-position on the map), tile id etc. So the docs are really confusing here.
  • Yes as I explained before its meant to be row column positions: starting from 1, as in 1;1 would be first row, first column

    And yes docs really need some work, we do what we can there, sorry ;)
  • MauMauMauMau Member
    edited October 2013
    So tx and ty are the column and row of a tile on the tile's texture image then?

    And regarding the automatic culling (hiding tiles that are off-screen):

    1.) Are TileMaps culled only if they are positioned directly using :setX() / :setY() or even when they are placed within a parent sprite and only that parent sprite is moved around then?

    For example:

    MainSprite
    ---Sprite
    ------TileMap
    ------TileMap
    ------TileMap
    ---Sprite
    ------TileMap

    When I move MainSprite around, does automatic culling still appear with all nested TileMaps within?

    2.) Does culling still work properly if a TileMap's parent is scaled -or even rotated?



  • ar2rsawseenar2rsawseen Maintainer
    edited October 2013
    Yes TileMap supports view frustum (offscreen) culling even with transformations (changing position, rotation etc)
    What, I think, it does not support, is occlusion culling, as in even if your TileMap is covered by another object and is not visible, it still will be rendering, will need to check that.
  • I did a test on the device and TileMap performance seems indeed quite good :-)
  • olegoleg Member
    edited November 2019
    How to change the diagonal to the other side?

    TileMap.FLIP_DIAGONAL


    I understood
    TileMap1:setTile(2,2,1,1,TileMap.FLIP_HORIZONTAL|TileMap.FLIP_VERTICAL )
    or
    TileMap1:setTile(2,2,1,1,6 )

    Likes: MoKaLux

    my games:
    https://play.google.com/store/apps/developer?id=razorback456
    мій блог по гідерос https://simartinfo.blogspot.com
    Слава Україні!
    +1 -1 (+1 / -0 )Share on Facebook
Sign In or Register to comment.