Translations of this page:

How to Make Scene Auto-scrolling In Wintermute Engine

BIG THANKS to anarchist for his kind advice and knowledge in scripting!

It is pretty common for adventure games that a scene auto-scrolls to a given point independently from actor. This scripted event can be easily achieved in WME.

Suppose, you have a scene background that exceeds the scene width. Whenever actor walks around the scene, it scrolls smoothly – you can see that in WME demo project. However you wish your scene could scroll to a given point automatically, without actor’s movement. As if a camera slid past actor to something you wanted to attract players’ attention.

Note: It is assumed in this tutorial that you have successfully covered http://docs.dead-code.org/wme/inside_scenes_step1.html and that the floor region in your scene is extended to the whole (even though actor isn’t going to walk during scene auto-scrolling, it is necessary for WME to “know” that the point that you want your scene to scroll is located within the walkable space).

Step 1

Open scene_init.script and add the following piece of code wherever you want scene auto-scrolling to happen:

Scene.AutoScroll = true; //The scene can scroll automatically. 
Scene.ScrollTo(); //Scroll the scene to a given point (X, Y) or another actor (sally).

Test your scene now. Nothing happens and the scene does not scroll anywhere. What is wrong?

Now if you open game.script you will find this line there:

Game.MainObject = actor;

It is written in WME Documentation online that

 Scene.Autoscroll: Specifies whether scene automatically scrolls to the Game.MainObject. 

So it makes sense that, when you set Game.Autoscroll to true the scene scrolls toward the main actor. Also the Documentation says:

 MainObject: The object which is used for the scene's auto-scrolling can be (set to) null. 

Since Game.MainObject in your game is actor, WME cannot scroll the scene to the point you want, unless Game.MainObject is set to null. Let’s correct this.

Step 2


Add a new line to your code:  
Game.MainObject = null;  
Scene.AutoScroll = true; //The scene can scroll automatically. 
Scene.ScrollTo(); //Scroll the scene to a given point (X, Y) or another actor (sally).

Come on, test the scene now. That’s it – it is auto-scrolling smoothly to the point that you wanted!

Step 3

And after you have done the scrolling add these two lines:

Scene.AutoScroll = false; //The scene cannot auto-scroll. 
Game.MainObject = actor; //Actor is MainObject again.

This way actor “gains control” over the scene (or whole game) again.

But what if you wanted to change the speed of auto-scrolling? What if it seems too slow or too fast?

ScrollSpeed is an attribute of the Scene object. As it is said in the Documentation http://docs.dead-code.org/wme/generated/scripting_ref_scene.html:

 ScrollSpeedX: Horizontal scrolling speed (in milliseconds, default=10) 
 ScrollSpeedY: Vertical scrolling speed (in milliseconds, default=10) 
 ScrollPixelsX: Horizontal scrolling shift (in pixels, default=1) 
 ScrollPixelsY: Vertical scrolling shift (in pixels, default=1) 
 OffsetX: Current horizontal scrolling offset of the scene 
 OffsetY: Current vertical scrolling offset of the scene. 

As you can see, you can choose between horizontal (X) and vertical (Y) scrolling speed.

By default ScrollSpeed is set to 10, so you need to specify another integer if you want to change scrolling speed.

Step 4 (optional)

Write in this line right before Scene.ScrollTo():

Scene.ScrollSpeedX = 2; //Default is 10, so this will make the scene scroll faster horizontally (along X coordinate).

If your wish is to slow things down, replace “2” from our example to “20” or any other integer.

Then run the game and enjoy.

 
kbase/how_to_make_scene_auto-scrolling_in_wintermute_engine.txt · Last modified: 2017/12/03 15:45 by Indra Anagram
Recent changes RSS feed Creative Commons License Driven by DokuWiki