ok I'm trying to script a puzzle where the user clicks on the piece of the puzzle and then drags it to where its supposed to go.
I have this code.
function noloopcheck oScroll1_Interact(){
while(mouse.IsButtonDown(eMouseLeft)){
oScroll1.X = mouse.x;
oScroll1.Y = mouse.y;
}
}
But I can't figure out how to update the screen while "dragging" the the item. I click and drag the item but it doesn't show that it moved until I release the left mouse button. Any ideas?
Haven't tested, but this may work.
function noloopcheck oScroll1_Interact(){
while(mouse.IsButtonDown(eMouseLeft)){
oScroll1.X = mouse.x;
oScroll1.Y = mouse.y;
Wait(1);
}
}
Further improvement:
function noloopcheck drag(Object*o);
int xa = mouse.x - o.X;
int ya = mouse.y - o.Y;
while(mouse.IsButtonDown(eMouseLeft)){
o.X = mouse.x - xa;
o.Y = mouse.y - ya;
Wait(1);
}
}
function oScroll1_Interact() {
drag(oScroll1);
}
Now the piece won't jump when you pick it up.
OOOOOOOoooooo Even better!!!!!!!
Thanks Guys!!!! ;D ;D ;D
Just a quick question: now that the Wait(1) is there, no_loop_check is not really necessary anymore, is it?