Background image top-to-bottom smooth scrolling

Started by bx83, Fri 09/03/2018 12:21:33

Previous topic - Next topic

bx83

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?

Slasher

You could check out the Tween Module... It's easy to use once you get the hang of it..

Matti

Normally you would just move the viewport to accomplish this. Did you try if that results in flickering?

Khris

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.

bx83

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?

bx83

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?

Crimson Wizard

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).

bx83

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.

Gurok

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:

Code: ags
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
[img]http://7d4iqnx.gif;rWRLUuw.gi

Slasher

And if you want to change a Room's Transition to the next Room in script you can add this:

Code: ags

SetNextScreenTransition(eTransitionBoxout); // Or whatever you wish it to be.. Could also be SetNextScreenTransition(3);
player.ChangeRoom(10);  // player that changes Room

bx83

Fabulous :)

And another thing...

I've come across a problem running this code:

Code: ags

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:

Code: ags

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. :/

Khris

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).

bx83

Here's the working code for anyone needing it:

Code: ags

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);
				}
			}
		}
	}
}

SMF spam blocked by CleanTalk