Hi all,
I'm trying to make ye olde favourite puzzle - the torn letter that must be put back together puzzle.

So, I want to be able to click a sprite on screen and while the mouse button is down, drag it around the screen. I didn't find any way to already do this so I did some script:
#include "scripts\base.inc"
var MoveTest = Scene.GetNode("move_test");
var IsLeftDown = false;
////////////////////////////////////////////////////////////////////////////////
on "LeftClick"
{
IsLeftDown = true;
while(true)
{
if (IsLeftDown==true)
{
MoveTest.X = Game.MouseX;
MoveTest.Y = Game.MouseY;
Sleep(50);
}
}
}
on "LeftRelease"
{
IsLeftDown = false;
MoveTest.X = MoveTest.X;
MoveTest.Y = MoveTest.Y;
}
This works fine whilst the left button is down, but when it's released, the game crashes. So, obviously something is wrong. Something probably to do with the "leftrelease" part I think.
EDIT:
Sorted it out.

#include "scripts\base.inc"
var MoveTest = Scene.GetNode("move_test");
var IsLeftDown = false;
////////////////////////////////////////////////////////////////////////////////
on "LeftClick"
{
IsLeftDown = true;
while(IsLeftDown==true)
{
MoveTest.X = Game.MouseX;
MoveTest.Y = Game.MouseY;
Sleep(50);
}
}
on "LeftRelease"
{
IsLeftDown = false;
MoveTest.X = MoveTest.X;
MoveTest.Y = MoveTest.Y;
}