Layer sorting with iso map

0 favourites
  • 2 posts
From the Asset Store
A template which allows you to customise the controls of your game.
  • Hi,i want to make player buy/place object on this isometric map but there is this problem (Picture 1).How can i make object closer to this blue line (Picture 2) be layer above than the object further from it.I had idea to make 7 layers for 7 tiles and then an object that will be placed on certain tile will be assigned with certain layer.So i don't know is my idea good or bad?Is there more simple way of doing this ? And if my idea is good i would need to make some kind of "grid tile" so when someone is trying to place object it will snap to tile.

    So basically what i need help with :

    -Need help with layer sorting when object is placed

    -How to make object snap to grid of tile(and how to make that grid)

    -How to detect where object is placed and change it's layer

    If you have any ideas i'll be glad to hear them <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" />

    Pic 1- imgur.com/a/wVvb9

    Pic 2- imgur.com/a/xHvJn

    Pic 3- imgur.com/a/0zubs

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Denmla, to answer the question of sorting, it can be as simple as using C2's 'Sort Z Order'. The docs state:

    [quote:345z7z4s]Sort Z order

    Sort the Z order of instances of a given object according to an instance variable. This effectively removes all instances from their Z order, sorts them, then inserts the sorted sequence back in to the holes left behind. This means if the instances are spread across a range of layers, they will be sorted in the same Z order locations, maintaining the same order relative to other instances on those layers. Note this action is much faster than using an ordered For each with an action like Send to front/back, so this action should be the preferred way to sort the Z order of large numbers of instances.

    Create a new instance variable -- call it 'sort' -- for all sprites that needs to be sorted. Then set the 'sort' variable's value to the sprites's Y coordinates. Then call 'Sort Z Order'.

    However, if you want to snap to grid, you can make a custom function for this, but a practical solution really depends on how you've already set up your scene.

    My real suggestion, especially if you are thinking of expanding an isometric map, is to use a combination of Tiled and Rex's TMX importer, and Rex's Board plugin and SquareTx plugin (and other Board-related plugins that fit your gameplay).

    The Tiled app (TMX) will enable you to generate an isometric map using logical coordinates (grid coordinates).

    Rex's Board plugin will create a virtual board, so that you can start working in logical coordinates (rather than screen coordinates). The SquareTx plugin will make the Board 'graphical', or project the Board's logical coordinates into screen space. This makes it easier to manage a map, because you'll be only concerned with the logical coordinates, and you let SquareTx handle the projection of the graphics onto the map.

    Rex's TMX Importer will take the TMX info and using SquareTx, places the tile sprites on the Board.

    I could say more about this, but there are so many details. I have to say that making functional isometric grids in C2 is not very simple without these plugins. However, these plugins require you to study them carefully as well, but it's better than writing many functions to achieve the same effect.

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