Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Scrolling and dynamically adjusting Scene.Width  (Read 7282 times)

0 Members and 1 Guest are viewing this topic.

theflash

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 34
    • View Profile
Scrolling and dynamically adjusting Scene.Width
« on: February 04, 2010, 12:11:37 PM »

Hello again,

for once I hope to post something that doesn't either solve itself or is so banal that I have to smack myself for stupidity.

I want to implement a Menu-Screen in my project that "slides" in and out, thus using Scene.ScrollTo . Now I know how to make Scenes scroll. But all the Scenes in my project have a mainlayer width of 1024, same as the game and thus non-scrolling. So I want to adjust the mainlayer width by script and make the scenes scrollable dynamically.

To accomplish that, I attach a menu.script at the press of the Escapekey, that does the following:
Code: [Select]
var MainL = Scene.MainLayer;
MainL.Width = 2048;

Scene.ScrollPixelsX = 30;
Scene.ScrollPixelsY = 30;
Game.MainObject = null;
Scene.AutoScroll = true;

Scene.ScrollTo(1536, 0);
}

If I set the MainLayer width MANUALLY in the Scene Editor to 2048, it works.

But if I set the Width in the script as above, it doesn't. The width is correctly identified by the game as 2048, yet it won't scroll.

Any ideas?
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Scrolling and dynamically adjusting Scene.Width
« Reply #1 on: February 04, 2010, 12:36:35 PM »

I'd classify this as WME bug. The scene keeps the width separately for scrolling purposes, and changing the width of the main layer doesn't update this infomation (it should).
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

theflash

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 34
    • View Profile
Re: Scrolling and dynamically adjusting Scene.Width
« Reply #2 on: February 04, 2010, 01:51:45 PM »

Ok. Thanks.

At least this time it wasn't me.
Logged

theflash

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 34
    • View Profile
Re: Scrolling and dynamically adjusting Scene.Width
« Reply #3 on: February 04, 2010, 04:20:27 PM »

OK, I might've found another scrolling-related bug.

To circumvent the above found one, I just made all scenes 2048 wide to begin with, to account for the possibility of sliding in (scrolling) the menu. And that worked.

Now I needed to pause the game, while I was in the menu, otherwise you'd be sliding out the game to one side and it would continue to run.

The only way I've found to pause the game is with the GoSystemExclusive() applied to a window. Once a window is system exclusive, it's the only thing clickable, so the sliding menu had to be the window. Windows themselves don't scroll, so I have my "Menu Dummy" (simple entity with pic) slide in, afterwards overlay it with the "Menu Window" (that looks indentical) and make this Menu Window system exclusive. When the menu should go away, I Delete the Menu Window and then slide out the Menu Dummy. This is when WME crashes. Always.

To reiterate:

- Main Layer is 2048.
- Scene background is 1024

on "Escape":
- "Menu Dummy" Entity is created and given an image
- Menu Dummy is placed at X = 1024
- Scene.ScrollTo(1536, 0) -> Slides out Scene background, slides in Menu Dummy
- Menu Window is loaded -> X = 0, Y = 0, Width = 1024, Height = 768 ... overlays the Menu Dummy
- Menu Window GoSystemExclusive();

on "Resume":
- Menu Window is killed
- Scene.ScrollTo(0, 0) -> Slides out Menu Dummy, slides in Scene background

After SCROLLING is FINISHED the GAME CRASHES.

Here is the code:

slider.script is called from game.script at the press of "Escape":

Code: [Select]
#include "scripts\base.inc"
#include "scripts\keys.inc"

global inMenu = true; // to prevent calling the Menu if it is already loaded

// Menu Dummy
var menu = Scene.CreateEntity("Menu_1");
menu.SetSprite("scenes\Menu\menue_bg.png");
menu.X = 1024;

// Scroll Scene
Game.MainObject = null;
Scene.ScrollPixelsX = 30;
Scene.ScrollPixelsY = 30;
Scene.AutoScroll = true;
Scene.ScrollTo(1536, 0);

// Overlay Menu Dummy with the actual Menu Window
global Win = Game.LoadWindow("windows\menu.window");
Win.X = 0;
Win.Y = 0;
Win.GoSystemExclusive();    

// kill the Menu Window and slide out Menu Dummy
// gets called from the other script
on "QuitMenu"
{
inMenu = false;
Game.DeleteWindow(Win);
Scene.ScrollTo(0, 0);
Scene.DetachScript("scripts\menu.script");
}

menu.script is attached to menu.window
Code: [Select]
#include "scripts\base.inc"
#include "scripts\keys.inc"

// if the "Resume"-button is clicked, QuitMenu is called (that works)
on "Resume"
{
Scene.ApplyEvent("QuitMenu");
}
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Scrolling and dynamically adjusting Scene.Width
« Reply #4 on: February 04, 2010, 04:38:56 PM »

This is way too complex for trying to reproduce, so I'll have to ask you for a simple repro project.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

theflash

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 34
    • View Profile
Re: Scrolling and dynamically adjusting Scene.Width
« Reply #5 on: February 04, 2010, 05:14:52 PM »

Okay, I mailed you a demo project.
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Scrolling and dynamically adjusting Scene.Width
« Reply #6 on: February 04, 2010, 08:00:11 PM »

Thanks!
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.019 seconds with 23 queries.