Author Topic: character actions with eBlock stop scrolling background  (Read 204 times)

I have some issues with making my character walk and pick up an object while scrolling the parallax background.
- the game resolution is 428 px in width but the background is 320 px (the remaining space is a GUI), therefore I fixed it with SetViewPort depending on the character's X-position.
- there is a parallax scrolling background which works pretty well
The problem appears when the character is doing something. Blocking stops the scrolling, and NoBlock runs the functions at once. What I need is making the character go to position xy and then pick up an object (change view etc), do you have any suggestions? I think, there is a solution using the rooms repeatedly_execute function but in my opinion, that's quite inconvenient.

Re: character actions with eBlock stop scrolling background
« Reply #1 on: 13 Feb 2019, 15:30 »
I fixed it with SetViewPort depending on the character's X-position
Where are you calling the code that does this?
If it is in repeatedly_execute or room_RepExec it would probably work to use repeatedly_execute_always instead.

Re: character actions with eBlock stop scrolling background
« Reply #2 on: 13 Feb 2019, 22:01 »
I fixed it with SetViewPort depending on the character's X-position
Where are you calling the code that does this?
If it is in repeatedly_execute or room_RepExec it would probably work to use repeatedly_execute_always instead.
I put it in the global script's room_RepExec function, putting it in repeatedly_execute_always helped. THANX!, now I have to solve the problem with the parallax scrolling, the function is object-related and in the room-script

edit: problem solved, simple but effective


function repeatedly_execute_always() {
 
  if(player.x > gTextBar.Width/2){
        SetViewport(cBrick.x -gTextBar.Width/2, 0);
        }
 
  if(Room.GetProperty("parallax") && object[0].Name == "sky"){
        object[0].X = GetViewportX()/2;
        }
}

« Last Edit: 13 Feb 2019, 22:28 by KiraHaraReturns »

Khris

  • having to deal with what games are going through
    • Lifetime Achievement Award Winner
    • I can help with play testing
    • I can help with scripting
    • I can help with translating
    • Khris worked on a game that was nominated for an AGS Award!
Re: character actions with eBlock stop scrolling background
« Reply #3 on: 13 Feb 2019, 22:16 »
Just add a function called repeatedly_execute_always to your room script, and it will get called.
Move all your parallax / viewport code for the room in there.

Room-specific code shoudn't be in the global script, and it usually doesn't have to be. Other functions that will just work without linking them are on_mouse_click and on_key_press.

(And just for reference: if you must put room-specific code in the global script (using on_event would be an example), simply wrap your code: if (player.Room == 3) { ... })
« Last Edit: 13 Feb 2019, 22:19 by Khris »

Re: character actions with eBlock stop scrolling background
« Reply #4 on: 13 Feb 2019, 22:42 »
@Khris
thank you for the suggestion, but I like the function to be global, it's in a if-loop now and is going to be activated when the room property is appropriate. I hope this will be fine now, if not I will follow your advice


function repeatedly_execute_always() {
 
  if(Room.GetProperty("parallax")){
        if(player.x > gTextBar.Width/2){
        SetViewport(cBrick.x -gTextBar.Width/2, 0);
        }
       
        if(object[0].Name == "sky"){
        object[0].X = GetViewportX()/2;
        }
    }
« Last Edit: 13 Feb 2019, 22:47 by KiraHaraReturns »