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":
#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
#include "scripts\base.inc"
#include "scripts\keys.inc"
// if the "Resume"-button is clicked, QuitMenu is called (that works)
on "Resume"
{
Scene.ApplyEvent("QuitMenu");
}