Hey Everyone!
This may sound like an idiotic question..but I really need some help understanding a few things.
What I'm doing is creating a mini-puzzle game where the user has to rearrange some puzzle pieces. Simple.
So heres what I have:
//at top of room script
int posX;
int posY;
function Drag(Object *Piece)
{
posX = mouse.x - Piece.X;
posY = mouse.y - Piece.Y;
while (Mouse.IsButtonDown(eMouseLeft)
{
Piece.X = mouse.x - posX;
Piece.Y = mouse.y - posY;
Wait(1);
}
}
Then in the object interaction function I simply used Drag(oPiece); etc
Which works exactly as it should. But heres the issue. I dont want to have to hold down click to drag it. I just want to click once. and have it lock to the mouse cursor. So I figured some sort of on_mouse_click would work. And I need This to happen constantly. So I figured i'd need to put something in repexec (which also confuses me because why when putting this code in the object interaction it runs like something would in repexec). But I cant do function on_mouse_click in repexec because i cant nest functions. This has my head spinning in circles. Do I need to do something like a processclick? OR do I need to use Any Click On Object event? Still, I am under the impression that having something stick with the mouse cursor at all times needs to be repeatedly executed ( but apparently object interaction events dont?). I am even more confused when I think about this. Maybe I'm not fundamentally understanding repexec.
Sorry to bug you guys!
-Thanks
-Josh
Nevermind,
Sorry guys I figured it out.
What I did was create a bool that gets set to true when the object AnyClick event is fired. And in the RepExec I just did if (isclicked == true) and set the object to the mouse. Sorry for wasting a post.
Take care
-Josh
//at top of room script
int posX;
int posY;
function Drag(Object *Piece)
{
posX = mouse.x - Piece.X;
posY = mouse.y - Piece.Y;
if Mouse.IsButtonDown(eMouseLeft)
{
Piece.X = mouse.x - posX;
Piece.Y = mouse.y - posY;
}
}
repeatedly_execute() {
Drag(SomeObject);
}