HELP! Room not positioning correctly.

Started by Bandersnatch, Mon 20/02/2012 03:10:58

Previous topic - Next topic

Bandersnatch

I recently added a new room with a resolution of 320x280. I want my character to appear at the bottom of the room and the bottom half of said room to be visible. However, when I test the game, the visible area is the centre of the room and the bottom (and player character) are hidden behind the GUI.

Any ideas?

:'(

antipus

The command that you're looking for is SetViewport(x, y), where x and y are the top-left coordinates of where you want the screen to be.  For example, if your screen resolution is 320 x 200, but your background is "too big," you could use

SetViewport(0, 79);

Note that this command "locks" the camera (or viewport) in place.  So if you want the camera to follow the character around once they start walking, you'll need to use

ReleaseViewport();

command.  Hope this works out for you!
Playing Arden's Vale has been shown to improve morale, revive unconscious kittens, and reverse hair loss.

Bandersnatch

Hi,

I've tried the SetViewPort function and can see what it does, but the problem persists. The view can lock itself in a higher position on the room but not a lower one, which is what Im wanting. Why might that be? Once back from work I'll post some screengrabs.

Snarky

The view can only go so far down that the bottom of the screen is at the bottom of the room. If you have a GUI that covers the bottom of the screen, that means part of the room is going to be hidden behind it.

So the solution, if you want to be able to scroll even further down, is to add padding to the bottom edge of the room that matches the height of your GUI, and reimport the background.

Bandersnatch

I had a feeling that might be the best thing for it - thanks for the advice, I'll give that a go. Now out of interest, how would I get the view to scroll very quickly to the upper half of the background and then back down again in a cutscene as if to simulate the player character glancing upwards?

Snarky

I always use the Tween Module: for all your scrolling/gradual movement needs and more!

Then you can just do:

Code: ags

  TweenViewportY(0.5, 0, eEaseInEaseOutTween, eBlockTween); // Pan up to the sky
  TweenViewportY(0.5, Room.Height-System.ViewportHeight, eEaseInEaseOutTween, eBlockTween); // Pan back down


(The 0.5 means it takes half a second to glance up, then half a second to come back down.)

Bandersnatch

Why thank you Snarky! I'll get right on it!

Glad these forums are looking like they're stable again.

SMF spam blocked by CleanTalk