Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: How does one control scrolling on a scene or entity?  (Read 5844 times)

0 Members and 1 Guest are viewing this topic.

sharkgod999

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 8
    • View Profile
    • The Salty Sea Cove
How does one control scrolling on a scene or entity?
« 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.
Logged
Freedom - Free = DUMB!

atm_deev

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 69
  • A. Deev
    • View Profile
    • CreativeDream Studio
Re: How does one control scrolling on a scene or entity?
« Reply #1 on: November 09, 2007, 06:50:02 AM »

try so:

Code: [Select]
Scene.AutoScroll=true;
Scene.ScrollTo(1000, 600);
« Last Edit: November 09, 2007, 06:54:54 AM by atm_deev »
Logged

atm_deev

  • Occasional poster
  • **
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 69
  • A. Deev
    • View Profile
    • CreativeDream Studio
Re: How does one control scrolling on a scene or entity?
« Reply #2 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);
Logged

sharkgod999

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 8
    • View Profile
    • The Salty Sea Cove
Re: How does one control scrolling on a scene or entity?
« Reply #3 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();

Logged
Freedom - Free = DUMB!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: How does one control scrolling on a scene or entity?
« Reply #4 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).
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

sychron

  • Wanderer zwischen den Welten
  • Global Moderator
  • Regular poster
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 223
  • There is no spoon. The enemy gate is down!
    • View Profile
Re: How does one control scrolling on a scene or entity?
« Reply #5 on: November 12, 2007, 12:09:38 PM »

And ... just to make sure ... Is the scene large enaugh to scroll to your destination position?
Logged
... delete the inner sleep ...

sharkgod999

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 8
    • View Profile
    • The Salty Sea Cove
Re: How does one control scrolling on a scene or entity?
« Reply #6 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?
Logged
Freedom - Free = DUMB!

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: How does one control scrolling on a scene or entity?
« Reply #7 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.
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

sharkgod999

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 8
    • View Profile
    • The Salty Sea Cove
Re: How does one control scrolling on a scene or entity?
« Reply #8 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);
}
///////////////////////////////////////////////////////////////////////////////////
Logged
Freedom - Free = DUMB!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: How does one control scrolling on a scene or entity?
« Reply #9 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.  
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.027 seconds with 25 queries.