Adventure Game Studio | Forums

AGS Support => Beginners' Technical Questions => Topic started by: bx83 on Fri 09/03/2018 12:21:33

Title: Background image top-to-bottom smooth scrolling
Post by: bx83 on Fri 09/03/2018 12:21:33
I want to move a large image (1024x7068) from top-to-bottom, on a 1024x768 room screen. This is for the credits.
Can I do it without flicker/jaggedness?
Can I do it *at all*, or should I find a module?
Title: Re: Background image top-to-bottom smooth scrolling
Post by: Slasher on Fri 09/03/2018 12:25:02
You could check out the Tween Module... It's easy to use once you get the hang of it..
Title: Re: Background image top-to-bottom smooth scrolling
Post by: Matti on Fri 09/03/2018 13:18:12
Normally you would just move the viewport to accomplish this. Did you try if that results in flickering?
Title: Re: Background image top-to-bottom smooth scrolling
Post by: Khris on Fri 09/03/2018 13:23:12
In case you took the "if all you have is a hammer" route and let an invisible character walk down the room, that will result in choppy scrolling due to the fact that the character moves multiple pixels every few frames.
Title: Re: Background image top-to-bottom smooth scrolling
Post by: bx83 on Fri 09/03/2018 21:59:29
Quote from: Matti on Fri 09/03/2018 13:18:12
Normally you would just move the viewport to accomplish this. Did you try if that results in flickering?

Sounds good, how to I do that? What function? Should I have the background as the tall credit's background and move the viewport down?
Title: Re: Background image top-to-bottom smooth scrolling
Post by: bx83 on Fri 09/03/2018 22:04:38
Quote from: Slasher on Fri 09/03/2018 12:25:02
You could check out the Tween Module... It's easy to use once you get the hang of it..

Which function in Tween should I use?
Title: Re: Background image top-to-bottom smooth scrolling
Post by: Crimson Wizard on Fri 09/03/2018 22:11:49
Quote from: bx83 on Fri 09/03/2018 21:59:29
Quote from: Matti on Fri 09/03/2018 13:18:12
Normally you would just move the viewport to accomplish this. Did you try if that results in flickering?

Sounds good, how to I do that? What function? Should I have the background as the tall credit's background and move the viewport down?

You may put the image on the object and move the object up, or put the image on room background and move viewport down.
To change viewport position see function SetViewport(x, y) and ReleaseViewport (you would need to call latter if you return from credits screen to another room).
Title: Re: Background image top-to-bottom smooth scrolling
Post by: bx83 on Mon 12/03/2018 04:54:39
Hey again
I'm, building my room with CW's last suggestion, no stutter :)

Just wondering, how do I get the room transition as instant, rather than fade out/fade in?
When I load this room, it fades in from black for about 500ms - how do I make it 0ms?

Checked setgameoption, no luck.
Title: Re: Background image top-to-bottom smooth scrolling
Post by: Gurok on Mon 12/03/2018 05:44:38
In the editor, go to General settings -> Visual -> Default transition when changing rooms and set it to Instant

If you really want to use SetGameOption, you might try:

SetGameOption(19, 1);

19 is OPT_FADETYPE, but I don't think the editor defines it. The transition styles are:

FadeOutAndIn = 0
Instant = 1
Dissolve = 2
BlackBoxOut = 3
CrossFade = 4
Title: Re: Background image top-to-bottom smooth scrolling
Post by: Slasher on Mon 12/03/2018 09:42:29
And if you want to change a Room's Transition to the next Room in script you can add this:

Code (ags) Select

SetNextScreenTransition(eTransitionBoxout); // Or whatever you wish it to be.. Could also be SetNextScreenTransition(3);
player.ChangeRoom(10);  // player that changes Room
Title: Re: Background image top-to-bottom smooth scrolling
Post by: bx83 on Mon 12/03/2018 10:47:19
Fabulous :)

And another thing...

I've come across a problem running this code:


function room_Load()
{
cJulius.Transparency=100;
cJulius.x=2000;
cJulius.y=2000;
gIconbar.Clickable=false;
gIconbar.Visible=false;
mouse.Mode=5;
SetGameOption(OPT_CROSSFADEMUSIC, 0); //set crossfade to 'no crossfade' for music_chan
music_chan=aTitleTheme_1_6_1.Play(eAudioPriorityNormal, eOnce);
}

function room_RepExec()
{
if (oCredits.Y>=850) {
oCredits.Y-=1;
} else {
if (music_chan.PlayingClip!=aTitleTheme_1_6_1) {
SetTimer(TIMER_WAIT, GetGameSpeed()*2);

if (IsTimerExpired(TIMER_WAIT)) {
FadeOut(5);
sounds_chan=aBlowing_out_a_match_2.Play(eAudioPriorityNormal, eOnce);
QuitGame(0);
}

}
}
}


I set break points, but it's forever jumping between these 2 lines:


SetTimer(TIMER_WAIT, GetGameSpeed()*2);

if (IsTimerExpired(TIMER_WAIT)) {


It then never ends.

My original idea was to Wait() 2 seconds, then turn the game off, but the Wait icon appeared; I was trying to get the mouse pointer set to something else, but nothing worked within the Wait() loop, when it would be changed to the little watch-face anyway. Finally, I thought of setting a timer; but it just loops forever. :/
Title: Re: Background image top-to-bottom smooth scrolling
Post by: Khris on Mon 12/03/2018 11:00:37
The condition of the block that sets the timer doesn't change, so the timer gets set again and again and again (and therefore never expires).
Title: Re: Background image top-to-bottom smooth scrolling
Post by: bx83 on Tue 13/03/2018 07:14:52
Here's the working code for anyone needing it:


function room_Load()
{
gIconbar.Clickable=false;
gIconbar.Visible=false;
RunCreditsNow=true;
SetGameOption(OPT_CROSSFADEMUSIC, 0); //set crossfade to 'no crossfade' for music_chan
music_chan=aSong.Play(eAudioPriorityNormal, eOnce);
}

function room_RepExec()
{
if (RunCreditsNow) {
mouse.Mode=5;    //blank action
if (oCredits.Y>=690) {
oCredits.Y-=1;
SetTimer(TIMER_WAIT_3SECONDS, GetGameSpeed()*3);
} else {
if (music_chan.PlayingClip!=aSong) {
if (IsTimerExpired(TIMER_WAIT)) {
FadeOut(10);
QuitGame(0);
}
}
}
}
}