• 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!

GameMaker Network drawing from one window to another.

deadfish

Member
I have 2 basic projects that only contain objects needed to connect to each other. One project being for the client and the other is the server. The client passes mouse_x and mouse_y location to the server and is then read through an async event. Then finally the mouse coordinates from client are printed out in the server's output window. This all currently works.

Now I want to be able to make instances appear in other windows. I know that instance_create has been deprecated and no longer works at run time so either instance_create_depth() or instance_create_layer() is needed. Though I'm not fully sure what either are fully doing or if i'm even using them correctly.

I figured this code would create a circle on the server window exactly where it was clicked on in the client window. I don't believe I need to pass the client's layer id or anything of that sort through the buffer if they have the same room size. But I could be wrong.
Code:
//create event code
var layer_id = layer_get_id("Background");

//async event code
var m_x = buffer_read(buffer, buffer_u32); // mouse x
var m_y = buffer_read(buffer, buffer_u32); // mouse y
instance_create_layer(m_x, m_y, layer_id, obj_circle);
//the obj_circle has a draw event on the server project that uses draw_circle_color()
then I tried the same with instance_create_depth()

Code:
//create event code
var layer_id = layer_get_id("Background");
var layer_dpt = layer_get_depth(layer_id);

//async event code
var m_x = buffer_read(buffer, buffer_u32); // mouse x
var m_y = buffer_read(buffer, buffer_u32); // mouse y
instance_create_depth(m_x, m_y, layer_dpt, obj_circle);
Any direction is greatly appreciated. Thank you for reading.
 

deadfish

Member
Nvm I got it to work.

I changed the instance_create_layer() from taking a background layer as a parameter to the instances layer since I was trying to load in an object.
instance_create_layer(m_x,m_y, "Background", obj_circle); -----> instance_create_layer(m_x, m_y, "Instances", obj_circle);
 
Top