Layer sorting with iso map

Get help using Construct 2

Post » Sun Jun 11, 2017 7:06 pm

Message: Denmla can only post plain text URLS until they have 500 rep. 3 URLS modified. Why?
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 :)
Pic 1- http://imgur.com/a/wVvb9
Pic 2- http://imgur.com/a/xHvJn
Pic 3- http://imgur.com/a/0zubs
B
4
Posts: 11
Reputation: 222

Post » Mon Jun 12, 2017 3:42 am

@Denmla, to answer the question of sorting, it can be as simple as using C2's 'Sort Z Order'. The docs state:

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.
B
42
S
12
G
1
Posts: 74
Reputation: 2,992


Return to How do I....?

Who is online

Users browsing this forum: blackhornet and 8 guests