GMS 2 Drawing game elements from a DS_GRID


Hey Guys,

I am migrating an isometric game from GMS 1.x to GMS 2 and I run into a complex question I should decide and I would like to hear a few ideas.

In the old system I used a few ds_grids that were storing all graphics in it and a script was redrawing all elements with the tile_add function to the proper depths.

In GMS2 depth and tiles are being dealt very differently so I have to decide how I should recreate the whole system. So I have all date saved in these ds_grids the only question which method could work out the best and fastest:

1. Sprite Layers
With a new script all elements can be drawn to a sprite_layer with a method like this:

///Build command sends data to a new script dsgrid x,y

obj =argument0;

if obj=140{
global.back_layer[argument1,argument2] = layer_create(100-argument1-argument2);
global.back_sprit = layer_sprite_create(global.back_layer[argument1,argument2],(isoX*75),(isoY*75),spr_object_01);
*Right now method 1 is not yet working properly.

2. Stick with the old system and use re-generated tile_add script
After importing the 1.x project to 2.x the system created the following script for TILE_ADD:

/// @description Adds a new tile to the room, allowing customisation of its attributes, and returning its index.
/// @param background The background asset from which the new tile will be extracted.
/// @param left The x coordinate of the left of the new tile, relative to the background asset's top left corner.
/// @param top The y coordinate of the top of the new tile, relative to the background assets top left corner.
/// @param width The width of the tile.
/// @param height The height of the tile.
/// @param x The x position in the room to place the tile.
/// @param y The y position in the room to place the tile.
/// @param depth The depth at which to place the tile.
/// @returns {number} resource name for the new tile

var __back = argument0;
var __left = argument1;
var __top = argument2;
var __width = argument3;
var __height = argument4;
var __x = argument5;
var __y = argument6;
var __depth = argument7;

// Scan for a layer with the correct depth
var __layers = layer_get_all();
var __numlayers = array_length_1d(__layers);

var __layertouse = -1;
var __i;
for(__i = 0; __i < __numlayers; __i++)
    if (layer_get_depth(__layers[__i]) == __depth)
        // Don't bother checking names - we'll just add tiles to whatever layer is handy
        __layertouse = __layers[__i];

if (__layertouse == -1)
    // didn't find a layer of the correct depth, so create one
    __layertouse = layer_create(__depth);

// Now create a new tile element and add it to the layer
var __tile = layer_tile_create(__layertouse, __x, __y, __back, __left, __top, __width, __height);

return __tile;
Which one is a better method to use in the long run?

Thank you guys!