Wintermute Engine Forum

Wintermute Engine => Technical forum => Topic started by: sharkgod999 on November 08, 2007, 10:28:27 PM

Title: How does one control scrolling on a scene or entity?
Post by: sharkgod999 on November 08, 2007, 10:28:27 PM
I've been working on an adventure game for some time and decided to switch to WME. It has everything I need. There has been one snag:

I have a "Title Scene". In this scene there's a background. I want the background to scroll up and left 200p. So I include the following snippet in the script attached to the scene:
Code: [Select]
this.AutoScroll = true;
while(true)
{
  this.ScrollTo(-200,-200);
  Sleep(100);
}


This results in nothing. The scene simply scrolls up to around -48 or so. I even removed the code, and that's how I found out it did nothing because the scene still panned up. I just started learning WME. So, I'm a little in the dark on this. In case it's important the game resolution is 800x600 and the scene is 1000x800.
Title: Re: How does one control scrolling on a scene or entity?
Post by: atm_deev on November 09, 2007, 06:50:02 AM
try so:

Code: [Select]
Scene.AutoScroll=true;
Scene.ScrollTo(1000, 600);
Title: Re: How does one control scrolling on a scene or entity?
Post by: atm_deev on November 09, 2007, 06:52:52 AM
oh... You say entity? Ok - look:

Code: [Select]
Scene.AutoScroll=true;
var e_obj=Scene.GetNode ("table");
Scene.ScrollTo (e_obj);
Title: Re: How does one control scrolling on a scene or entity?
Post by: sharkgod999 on November 11, 2007, 09:18:56 PM
Quote
try so:

Code: [Select]
Scene.AutoScroll=true;
Scene.ScrollTo(1000, 600);
I tried this. the scene still scrolls to 0,53. Here is me script:
Code: [Select]
#include "scripts\base.inc"

// here comes the stuff which initializes the scene

Game.LOG("**Intro Scene**");

//actor.Reset();
actor.Active=false;

///////////////////////////////////////////////////////////////////////////////////
//  Scene.ScrollTo() stops the script.
Game.LOG("AutoScroll is turned on");
Scene.AutoScroll=true;
Game.LOG("Scene Scrolling to 1000,800");
Scene.ScrollTo(1000,800);

//////////////////////////////////////////////////////////////////////////////////
//  win.GoExclusive() stops the script as well.
Game.LOG("Loading Intro Window");
global win = Game.LoadWindow("scenes\Intro\Wnd\intro_menu.window");
win.Center();
win.GoExclusive();

Title: Re: How does one control scrolling on a scene or entity?
Post by: Mnemonic on November 12, 2007, 09:09:15 AM
Make sure to set

Code: WME Script
  1.  

The Game.MainObject property is the object which is used for automatic scrolling (in most cases you want the camera to follow the actor). But if you want to control scrolling manually, you need to set the MainObject to null (unknown value).
Title: Re: How does one control scrolling on a scene or entity?
Post by: sychron on November 12, 2007, 12:09:38 PM
And ... just to make sure ... Is the scene large enaugh to scroll to your destination position?
Title: Re: How does one control scrolling on a scene or entity?
Post by: sharkgod999 on November 13, 2007, 04:58:22 AM
Quote
Code: [Select]
Game.MainObject = null;

This stopped the scene from scrolling automatically and the scene scrolls as I want now ::rock. However, the window doesn't load till it has stopped scrolling. Is there a way to continue executing the script while still scrolling?
Title: Re: How does one control scrolling on a scene or entity?
Post by: metamorphium on November 13, 2007, 09:52:01 AM
place the code to the separate file and attach it through this.AttachScript("filename");

Code attached in such script would run independently.
Title: Re: How does one control scrolling on a scene or entity?
Post by: sharkgod999 on November 13, 2007, 10:21:58 AM
Thanks everyone! I got the scrolling to work, and I'm starting to get the idea behind the scripting language. Here's my working code if anyone has a similar issue. This does seem to have one issue. There's a bit of lag when the engine resets the offsets to 0.

Code: [Select]
///////////////////////////////////////////////////////////////////////////////////
//  Scroll Scene
while(true)  {
  Scene.ScrollTo(1000,800);
  if(Scene.OffsetX>=200)  {
    Scene.OffsetX=0;
  }
  if(Scene.OffsetY>=200)  {
    Scene.OffsetY=0;
  }
  Sleep(100);
}
///////////////////////////////////////////////////////////////////////////////////
Title: Re: How does one control scrolling on a scene or entity?
Post by: Mnemonic on November 13, 2007, 10:30:55 AM
Is there a way to continue executing the script while still scrolling?
I was about to say use ScrollToAsync() instead, but I found there's no such method, shame on me.
Perhaps more comfortable that using a separate script would be something like this:

Code: WME Script
  1. this.ApplyEvent("DoScrolling");
  2. // some code here which runs in parallel with scrolling
  3.  
  4.  
  5. on "DoScrolling"
  6. {
  7.   Scene.ScrollTo(100, 200);
  8. }
  9.