• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker [SOLVED] Drag and Drop bug?

GDK

Member
Below is the code I'm using for drag & drop of an object...

Code:
/// CREATE
selected = false;

/// STEP
if (selected){
    x = mouse_x;
    y = mouse_y;
}else{
    x = xstart; //return to initial x location
    y = ystart; //return to initial y location
}

/// LEFT PRESSED
selected = true;

/// LEFT RELEASED
selected = false;
It all works pretty much as I need it to, except for 1 minor issue/bug (hopefully my explanation is not too confusing)...

If I move my mouse extremely fast while holding LMB down to the point where the instance falls behind the mouse position AND release LMB, the instance then becomes fixed with mouse positionand follows it until i LMB press somewhere.
This is what I don't want to happen...

I have a feeling it's due to releasing the LMB while the instance is no longer under the mouse coordinates which then causes the true and false states to glitch out.

Any ideas?
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
Should probably use Global Left Released rather than Left Released - Left Released triggers only if the mouse is over the object, and if the object can't catch up to mouse because of order of operations... that happens.
 

MeBoingus

Member
Below is the code I'm using for drag & drop of an object...

Code:
/// CREATE
selected = false;

/// STEP
if (selected){
    x = mouse_x;
    y = mouse_y;
}else{
    x = xstart; //return to initial x location
    y = ystart; //return to initial y location
}

/// LEFT PRESSED
selected = true;

/// LEFT RELEASED
selected = false;
It all works pretty much as I need it to, except for 1 minor issue/bug (hopefully my explanation is not too confusing)...

If I move my mouse extremely fast while holding LMB down to the point where the instance falls behind the mouse position AND release LMB, the instance then becomes fixed with mouse positionand follows it until i LMB press somewhere.
This is what I don't want to happen...

I have a feeling it's due to releasing the LMB while the instance is no longer under the mouse coordinates which then causes the true and false states to glitch out.

Any ideas?

Change the 'LEFT RELEASED' event to 'GLOBAL MOUSE LEFT RELEASED' to resolve that.

EDIT: Beaten to it.

Here's an extra bit of advice, though - try using the "Begin Step" event instead. That should elviate the object delay issue.
 
  • Like
Reactions: GDK
Top