Panning a room

Started by Jojowl80, Tue 08/09/2020 23:51:15

Previous topic - Next topic

Jojowl80

I am trying to make my invisible player walk across a room to  to make it look like a cutscene. The room is 400 in length, so I want it topan to the other half of the room.

Code: ags


function room_Load()
{
aFog.Stop();
sAirplane.Play();
 player.Transparency = 100;
  gMain.Visible = false;

}


function room_AfterFadeIn()
{
Wait(200);
aOrcus.Play();
player.Move(35, 188, eBlock);
}



He starts on the right side of the room, but he doesn't move an inch from the spot he enters on.

Jack

#1
room_RepExec() is called every non-blocked frame, so in there you would move the viewport along in small increments with SetViewport.

Something like:

Code: ags

  int horizontalPosition = GetViewportX();
  if (horizontalPosition > 0)
  {
    SetViewport(horizontalPosition - 1, 0);
  }


This will decrease the vertical position by one pixel each frame. You can add more stuff to delay the starting of the scroll, like a bool to signal when it should scroll and not.

To move right, you would increase the horizontal position, and the if would look like:

Code: ags

if (horizontalPosition < Room.Width - System.ScreenWidth)


You should make the player move a non-blocking action so the rest of the script functions can run while it is moving, or handle the scrolling in the room's repeatedly_execute_always.

Khris

Have you drawn a walkable area? You can also use  eAnywhere  in the  .Move  command instead.

Cassiebsg

Also, this might be related to the fact that AGS does not move invisible objects/characters. You can try and set his transparency to 99 instead of 100 and see if it makes a difference.
But to pan the room, you don't really need a character to move, just use Jack's code.  ;) Though, if you are using the newer version of AGS (3.5) the command has been updated, and you should use the Camera command instead.
There are those who believe that life here began out there...

Crimson Wizard

Quote from: Cassiebsg on Wed 09/09/2020 17:05:19
Also, this might be related to the fact that AGS does not move invisible objects/characters. You can try and set his transparency to 99 instead of 100 and see if it makes a difference.

Not that's wrong, it moves transparent object, it does not move objects which have ".Visible = false" or ".on = false".

Cassiebsg

Okay, I wasn't sure if 100 was equal to false on either one of those, that's why I suggested to try it, since I am sure that 99 isn't.  ;)
There are those who believe that life here began out there...

SMF spam blocked by CleanTalk