• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

 Add new function? draw_layer()

Y

yakmoon

Guest
Hi,
its very important for every developer in this community to help improve this engine.
now as my part, I think there are many useful or rather necessary functions that should be added to this engine.
one of the necessary functions is drawing on a specific layer, since we have the new layer system, why not have a draw_layer function?
example1:
Code:
draw_text_layer("Hello",x,y,"layer");
draw_sprite_layer(sprite,subimage,x,y,"layer");
example 2:
Code:
draw_set_layer("layer");
draw_text("Hello",x,y);
I really insist on this function, its very important.
if you have a supportive or different opinion please leave a comment.
 
Last edited by a moderator:

rIKmAN

Member
Hi,
its very important for every developer in this community to help improve this engine.
now as my part, I think there are many useful or rather necessary functions that should be added to this engine.
one of the necessary functions is drawing on a specific layer, since we have the new layer system, why not have a draw_layer function?
example1:
Code:
draw_text_layer("Hello",x,y,"layer");
draw_sprite_layer(sprite,subimage,x,y,"layer");
example 2:
Code:
draw_set_layer("layer");
draw_text("Hello",x,y);
I really insist on this function, its very important.
if you have a supportive or different opinion please leave a comment.
You can already do this by creating objects (in the IDE or via code) on a certain layer and drawing using their draw events.

Write a script that wraps the layer/object commands and use the script to either create layers and objects if they don't already exist, or create/move an object to the correct layer if if does.
 
P

psyke

Guest
When I read the title of this topic, I thought that you were suggesting for a function to draw an entire layer in the draw event, and honestly, it would be pretty cool to have the possibility to draw layers into surfaces, but I guess this is not relevant to this topic. Sorry. :D
 
Y

yakmoon

Guest
You can already do this by creating objects (in the IDE or via code) on a certain layer and drawing using their draw events.

Write a script that wraps the layer/object commands and use the script to either create layers and objects if they don't already exist, or create/move an object to the correct layer if if does.
I am not new to Gamemaker, I know that you can do that, but what I am asking is completely different, if I use an object on a layer to do the job, then you'll have latency issues, because GMS runs through objects according to their order and execute codes on that order, and that will mess up a lot of things, but if you could directly access a layer and draw there, that object won't need to wait for the other object on that layer to execute the code.
I hope you understood what am talking about.
 
Y

yakmoon

Guest
When I read the title of this topic, I thought that you were suggesting for a function to draw an entire layer in the draw event, and honestly, it would be pretty cool to have the possibility to draw layers into surfaces, but I guess this is not relevant to this topic. Sorry. :D
That is a part of what I am suggesting.
 

rwkay

GameMaker Staff
GameMaker Dev.
OK I think you are describing the ability to add assets to a layer at runtime (like a sprite or text) - this is what an asset layer is, currently you can only add sprites to an asset layer (but we do plan on expanding this for text, and other assets in the future) - so you can already do this (for sprites).

see these functions

  • layer_sprite_get_id(layer_id,sprite_element_name) - get the element id with the sprite_element_name on the layer
  • layer_sprite_exists(layer_id,sprite_element_id) - return true if the layer has the sprite_element_id on it
  • layer_sprite_create(layer_id,x,y,sprite) - create a sprite element on layer at position x, y
  • layer_sprite_destroy(sprite_element_id) - destroy the sprite element
  • layer_sprite_change(sprite_element_id,sprite) - change the sprite index to use for the given sprite element
  • layer_sprite_index(sprite_element_id,image_index) - set the image index for the sprite element
  • layer_sprite_speed(sprite_element_id,image_speed) - set the image speed for the sprite element
  • layer_sprite_xscale(sprite_element_id,scale) - set the x scale for the sprite element
  • layer_sprite_yscale(sprite_element_id,scale) - set the y scale for the sprite element
  • layer_sprite_angle(sprite_element_id,angle) - set the angle for the sprite element
  • layer_sprite_blend(sprite_element_id,col) - set the colour tint value for the sprite element
  • layer_sprite_alpha(sprite_element_id,alpha) - set the alpha value for the sprite element (0..1)
  • layer_sprite_x(sprite_element_id,x) - set the x position of the sprite element
  • layer_sprite_y(sprite_element_id,y) - set the y position of the sprite element
  • layer_sprite_get_sprite(sprite_element_id) - get the sprite index for the sprite element
  • layer_sprite_get_index(sprite_element_id) - get the image index for the sprite element
  • layer_sprite_get_speed(sprite_element_id) - get the image speed for the sprite element
  • layer_sprite_get_xscale(sprite_element_id) - get the x scale for the sprite element
  • layer_sprite_get_yscale(sprite_element_id) - get the y scale for the sprite element
  • layer_sprite_get_angle(sprite_element_id) - get the angle for the sprite element
  • layer_sprite_get_blend(sprite_element_id) - get the colour tint value for the sprite element
  • layer_sprite_get_alpha(sprite_element_id) - get the alpha value for the sprite element
  • layer_sprite_get_x(sprite_element_id) - get the x position for the sprite element
  • layer_sprite_get_y(sprite_element_id) - get the y position for the sprite element
Russell
 

sylvain_l

Member
@rwkay no, reading his suggestion I think he is really asking to be able to draw on layer at run time. (or to have a similar feature)

@yakmoon you don't draw on layer, you draw on surface (by default the application surface)
layers are for your objects (be it full code object or simplified, like just sprite asset, tilemap, background,... ) and organize the z index a bit (which influence the order in wich those are drawn during draw event)
 
Y

yakmoon

Guest
@rwkay I am using this functions inside a script and feeding the arguments from a controller object.
example of script:
Code:
///draw_sprite(sprite,x,y,angle,alpha);
layer_sprite_x(argument0,argument1);
layer_sprite_y(argument0,argument2);
layer_sprite_angle(argument0,argument3);
layer_sprite_alpha(argument0,argument4);
in create event:
Code:
player_shadow=layer_sprite_create("shadow",x,y,sprite1);
in step or draw event:
Code:
draw_sprite(player_shadow,x,y,sprite_angle,1);
I was hoping for a function that does all that efficiently.
I am happy that you'll add the text functions, I hope to see it soon.
@sylvain_l ya I know that (you draw on surface), I know engines are made only to simplify things, and that's why am asking for this kind of functions, make it easier for me to control things.
 
Top