GML Object won't show up in room when placed/created

Discussion in 'Programming' started by Koops, Apr 27, 2019.

  1. Koops

    Koops Member

    Joined:
    Apr 27, 2019
    Posts:
    8
    The issue I'm having is that, no matter if I place the object inside a room or let it be created with a different object placed inside an instance layer, it doesn't show up in the room when testing the game.

    This problem arises when I play an object that has a sprite or no sprite at all.
    I want text to be shown in a text adventure style of game, but it suddenly doesn't want to appear.

    When I first created the object with no sprite and placed it inside the room, it showed the text, but suddenly it doesn't. I don't know what happened.

    When I placed another object with a sprite once, it showed up in the room editor, but not in the play test. Then weirdly enough, I had to add draw_sprite() in order for it to show up.

    Debug messages even showed me that the sprites exist, but are invisible. The Visible checkbox is even checked and I never unchecked it.

    What's exactly happening and is there a way to fix this problem?

    If you need more information, feel free to ask and I'll tell you. Because I understand if my english is a bit confusing, since I'm not a native english speaker. I apologize for that.
     
  2. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Joined:
    Apr 21, 2016
    Posts:
    1,633
    Did that object have a Draw event? Adding a Draw event translates to "don't draw this object's sprite, I will handle all drawing myself", so unless you explicitly draw the sprite, it won't be drawn.

    That aside, are you changing the draw alpha via draw_set_alpha anywhere? The effect of this is global and needs to be reset to the default value after performing a non-standard alpha draw to avoid one portion of code affecting others.

    If the problem persists, please post all relevant code.
     
  3. Koops

    Koops Member

    Joined:
    Apr 27, 2019
    Posts:
    8
    Yes, the object has draw events, but it has no sprite. It's just for displaying text. I'm not sure if there's a better way to do text in visual novel styled text adventures, besides just having it display the text and nothing else.

    Here's the code inside the draw event to display text. It has no sprites, it's empty.

    draw_set_halign(fa_left);
    draw_set_valign(fa_top);
    draw_set_font(fnt_text);
    draw_text_ext(310, 5, intro01, th, textboxWidth);
    draw_text_ext(310, pH02, intro02, th, textboxWidth);
    draw_text_ext(310, pH03, intro03, th, textboxWidth);
     
  4. Koops

    Koops Member

    Joined:
    Apr 27, 2019
    Posts:
    8
    Like I mentioned before, this displaying text object worked previously just fine, I don't know why it suddenly stopped working. My guess is that it must have something to do with the room? But the only thing I changed in the room was the grid size and that's not the problem. I'm really confused.
     
  5. SnortySnoopy

    SnortySnoopy Member

    Joined:
    Apr 25, 2018
    Posts:
    213
    If the object has sprite image, and have a draw event in it (e.g. text), add " draw_self(); " in the draw event at line 1.
     
    gamedev4life likes this.
  6. Toque

    Toque Member

    Joined:
    May 25, 2017
    Posts:
    1,047
    Is it being drawn but another object is in front of it?


    If you place in a new room with that only object is it drawn?

    Is it drawn but off the visible window?
     
  7. Koops

    Koops Member

    Joined:
    Apr 27, 2019
    Posts:
    8
    I know about the draw_self(); command. I had to create it to that one other object, which has a sprite image. Let's call it Object A.
    When I have the controller object creating Object A, it won't show up when it doesn't have any code inside it. I had to add draw_self(); for it to appear.

    Now, the other problem I keep mentioning is about the object, that has no sprite image attached to it. This is Object B. Let's just focus on Object B please.
    Object B is just an object that is for making the text show up, nothing more, nothing less. The code I posted above is just for drawing and placing the text that I set up in the Create event. Nothing else.

    No, even if the object is alone in the room, it still doesn't want to be drawn. Not Object A or Object B.
     
  8. Toque

    Toque Member

    Joined:
    May 25, 2017
    Posts:
    1,047
    “Create event” ??

    Shouldn’t it be in the draw event?

    I usually put draw stuff in draw event.
    This was already mentioned by moderator so maybe you tried that already.
     
  9. Koops

    Koops Member

    Joined:
    Apr 27, 2019
    Posts:
    8
    I apologize that it didn't seem clear enough.
    I said that I set up the text in the create event, which in the code I posted above is intro01, intro02 and intro03. The strings are in the create event. Everything I draw is in the draw event, that's something I knew before I posted this question.
    I hope that's a bit more clear. ^^
     
  10. Timothy

    Timothy Member

    Joined:
    Aug 7, 2016
    Posts:
    64
    This may seem obvious, but make sure visible is set to true (through debugger). Also check position.
     
    Last edited: Apr 28, 2019
  11. Toque

    Toque Member

    Joined:
    May 25, 2017
    Posts:
    1,047
    You will have to post all the code and maybe someone can help.

    I would start new project. Copy paste code and see if it works.

    If it still doesn’t show it’s the code.
     
    Last edited: Apr 28, 2019
  12. jackquake

    jackquake Member

    Joined:
    Aug 17, 2016
    Posts:
    81
    One more thing you might try as this one bit me a long time ago...

    Put a Draw_Set_color c_white (or draw_set_colour as you prefer) before you draw the text. Perhaps you have accidentally changed the color to the background color of the room and the text is there, you just can't see it.
     
    Timothy likes this.
  13. Koops

    Koops Member

    Joined:
    Apr 27, 2019
    Posts:
    8
    draw_set_color(c_white); helped. The text is visible. :D
    Maybe the standard color setting of text is black? I never thought about that.
    Thanks a lot for the help jackquake. And thanks for everyone who took the time and tried to help me. I appreciate it. :D
     
    jackquake likes this.

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