1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

[solved] Help! Making Score Follow View Vertically

Discussion in 'Programming' started by deadant88, Jul 15, 2018.

  1. deadant88

    deadant88 Guest

    Hi all,

    I have been searching for hours, tried 3 or 4 diff tutorials, scoured the forums/reddit/stack exchange, the GMS 2 manual and the GMS tutorials.

    I am trying to program the score object to remain on screen while the player object moves upwards on a level but it always remains static.

    Here is my code draw event code for my score object:

    var cx = camera_get_view_x(view_camera[0]);
    var cy = camera_get_view_y(view_camera[0]);
    var cw = camera_get_view_width(view_camera[0]);

    draw_text(cx + (cw / 2), cy + 1950, string(thescore));

    Here is my create event for obj_score

    thescore = 0

    Can anyone help me achieve this?

    Thanks you!
     
  2. Alexx

    Alexx Member

    Joined:
    Jun 21, 2016
    Posts:
    441
    It would be easier to place this in a Draw GUI Event.
    Just use:
    Code:
    draw_text(x,y,thescore);
    
    where are x and y are the locations you wish to draw at.
    This will draw independent of any view.
     
  3. deadant88

    deadant88 Guest

    Thanks so much for your reply Alexx. I have done what you suggested but the score is now not showing up at all on the view. I have copied the code and tried it as a draw event and it showed up, but when I tried again in draw gui ... no dice. I have tried putting in a range of different x, y coordinates but it still doesn't show up.

    If it makes any difference the dimensions of the room are 1024 x 2000, I am trying to make a tall game. This may not be the most optimal way to structure my level, so am happy to get feedback on that as well.

    Cheers
     
  4. Jrelvas

    Jrelvas Member

    Joined:
    Jul 14, 2018
    Posts:
    15
    Yep, just make it draw on draw gui!
     
  5. Alexx

    Alexx Member

    Joined:
    Jun 21, 2016
    Posts:
    441
    Please post the code you are using, so myself or someone else can see what may be wrong.
     
  6. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    7,143
    Remove cx and cy from your draw code in the GUI.
     
  7. NightOwlGameDev

    NightOwlGameDev Member

    Joined:
    Feb 1, 2018
    Posts:
    14
    You Are Using The Room Width And Hight ... Big OOPS.

    use The View Width And Height in the " Draw Gui Event."

    Code:
    draw_text(32,32, "TEXT GOES HERE");
     
  8. deadant88

    deadant88 Guest

    Omg NightOwlGame
    You sir, are my absolute hero. Thank you very much for your help.
     

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