• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Simple question

F

FeNniX

Guest
Hey. Really simple question: I have big room that uses views. Imported background that is exactly the same size as view. In order to center background I used code in step event:

background_x[0] = view_xview
background_y[0] = view_yview

Thing is, when the player moves edge of background becomes visible for split second (screenshot below) and then background centers again. When player stops edge is not visible. How can I make background don't move at all and stay statically in view?
 

Attachments

Yal

🐧 *penguin noises*
GMC Elder
Run your code in the following order:
  1. Player moves.
  2. View adapts to player position.
  3. Background adapts to view position.
This gets a bit tricky with GM's automated systems, but I think putting the code moving the background into the end step event should achieve this effect, if you don't want to do all three steps yourself.
 

NightFrost

Member
Yeah, you should always treat step events order between instances as undefined. While it can be observed that this generally happens in instance creation order, it could change in future updates, and GMS gives you no guarantees of any sort about their execution order (not even from frame to frame during runtime, I believe?). So if you have step event code in two instances that needs to run in specific order, the only completely safe method is to separate them via begin step - step - end step events.
 

Yal

🐧 *penguin noises*
GMC Elder
Yeah, you should always treat step events order between instances as undefined. While it can be observed that this generally happens in instance creation order, it could change in future updates, and GMS gives you no guarantees of any sort about their execution order (not even from frame to frame during runtime, I believe?). So if you have step event code in two instances that needs to run in specific order, the only completely safe method is to separate them via begin step - step - end step events.
Not the only way: you could have the code in scripts or User Defined Events, and have a controller call them in the correct order in its step event. It's a bit more extensible than how Begin - Normal - End step event only lets you total-order at most 3 events.
 
Top