GM:S 1.4 Background Sprite Placement *SOLVED*

Discussion in 'Programming' started by Odolwa, Sep 8, 2019.

  1. Odolwa

    Odolwa Member

    Joined:
    Jul 11, 2016
    Posts:
    57
    OK, the issue is that I wanted to move a non-repeating background sprite relative to the player, but to also place the sprite a bit ahead of the player when they enter the room. This is the parallax code:
    Code:
    background_x[1] = view_xview[0]*0.6;
    
    By doing this, I end up with a situation where the sprite is always placed at the far left of the room, where the player enters, rather than slightly farther ahead where I have placed it in the room editor. My question is, can I apply the parallax code 'and' also have the background sprite placed ahead of the player when they enter the room?
    Thank you.
     
  2. Goldoche

    Goldoche Member

    Joined:
    Dec 30, 2016
    Posts:
    33
    Try this maybe

    Code:
    background_x[1] = view_xview[0]*0.6 + offset;
    
    set the offset to the position you gave the background in the room
     
    Odolwa likes this.
  3. TheouAegis

    TheouAegis Member

    Joined:
    Jul 3, 2016
    Posts:
    6,780
    You can either put the offset at the end like that, or encapsulate the offset and the view between parentheses. That will result in a different positioning, so you would have to modify it a little.
     
    Odolwa likes this.
  4. Odolwa

    Odolwa Member

    Joined:
    Jul 11, 2016
    Posts:
    57
    That got it working! Thank you!
     

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