How to connect two objects?

Discussion in 'Programming' started by omid, Oct 7, 2019.

Tags:
  1. omid

    omid Member

    Joined:
    Oct 7, 2019
    Posts:
    7
    What do I need to do to connect the objects and the line between them?
    for skill tree game[​IMG]
    if mouse_check_button_pressed(mb_left)
    {
    i=instance_nearest(x,y,Cyc)
    draw_line_width_color(Cyc.x,Cyc.y,i.x,i.y,2,random(c_blue),random(c_red));
    }
     
  2. FrostyCat

    FrostyCat Member

    Joined:
    Jun 26, 2016
    Posts:
    4,556
    You're doing an awful job describing what you want, as I have no idea what a "skill tree game" is. Until you explain yourself better, I can only rehash your broken code.

    Create:
    Code:
    inst_linked = noone;
    Step:
    Code:
    if (mouse_check_button_pressed(mb_left)) {
      inst_linked = instance_nearest(x, y, Cyc);
    }
    Draw:
    Code:
    if (instance_exists(inst_linked)) {
      draw_line_width_color(x, y, inst_linked.x, inst_linked.y, 2, c_blue, c_red);
    }
    Also, you need to read this article: What's the difference: Objects and instances
     
    omid likes this.
  3. omid

    omid Member

    Joined:
    Oct 7, 2019
    Posts:
    7

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice