Problem with camera and instances

Discussion in 'Programming' started by Tarte, Jan 10, 2019.

  1. Tarte

    Tarte Member

    Joined:
    Jan 10, 2019
    Posts:
    30
    Hey! First of all thank you for reading my post. My question is the following :

    I'm creating a game maker game (GML) and I want to make a life bar for my character.

    Here is the code:

    Code:
    /// Quick Bar, Bar of Life and Mana Bar of the Character + Life of the Boss in relation to the camera:
    
    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])
    
    /// Manage the Character Life Bar:
    
    ObjBarreViePlayer.y = cy + 1675
    ObjBarreViePlayer.x = (cx + cw / 2) - 2000
    
    /// Management of the Mana Bar of the Character:
    
    ObjBarreManaPlayer.y = cy + 1900
    ObjBarreManaPlayer.x = (cx + cw / 2) - 2000


    (This is in the character's step and the objects are created at the beginning of the room)



    The problem is that when I move my character, the Bar of Life and Mana shifts to the right when I go to the left and to the left when I go to the right.
    (the number of pixels that my character is moving forward).



    Voila if you have answers I'm interested and I specify that this post has been translated with google translation (yes I'm French and not very good in English;)) Tanks :)
     
  2. Rob

    Rob Member

    Joined:
    Jul 12, 2016
    Posts:
    661
    Shameless plug:



    This should cover it! You are using an object to display those stats right?

    You don't have to copy the code in the video, hopefully the explanation will help.
     
  3. Tarte

    Tarte Member

    Joined:
    Jan 10, 2019
    Posts:
    30
    Ok thanks ;)
     
  4. Tarte

    Tarte Member

    Joined:
    Jan 10, 2019
    Posts:
    30
    Yes I using an object to display those stats.
    and thanks !
     
  5. Rob

    Rob Member

    Joined:
    Jul 12, 2016
    Posts:
    661
    No worries man
     

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