Using GM7 Pro
Edited by MattClark1000, 18 May 2010 - 04:20 PM.
Posted 18 May 2010 - 04:04 PM
Edited by MattClark1000, 18 May 2010 - 04:20 PM.
Posted 18 May 2010 - 04:13 PM
//create event
drag = 0
//step event
if keyboard_check(ord('X')){
if mouse_x = x and mouse_y = y //if X is pressed and the mouse is over the block..
drag = 1} //drag it
if drag = 1{
x = mouse_x
y = mouse_y}
if keyboard_check_released(ord('X'))
drag = 0 //if you stop pressing X the dragging stopsI don't have GM available currently, but I believe that code should work how you want
Edited by moomoo112, 18 May 2010 - 04:14 PM.
Posted 18 May 2010 - 04:16 PM
if place_meeting(x,y,obj_cursor)
{
if keyboard_check(ord("X"))
{
x = obj_cursor.x
y = obj_cursor.y
}
}Edited by Shorooq, 18 May 2010 - 04:24 PM.
Posted 18 May 2010 - 04:28 PM
Posted 18 May 2010 - 05:29 PM
Posted 18 May 2010 - 09:45 PM
hi.
if you like you can see at http://gmc.yoyogames...howtopic=249574
my platform lib, because have push/drag code.
sorry haven't gm here to make an example.
you can use the lib or you can see the code in the lib to get an idea
cu and gl
maybe at home download start again gm
Posted 18 May 2010 - 09:55 PM
if(place_meeting(x,y,obj_cursor)){
if(keyboard_check(ord('X'))){
x = obj_cursor.x;
y = obj_cursor.y;
}
}
Posted 19 May 2010 - 12:32 AM
This goes in the block's step event. Change obj_cursor to the cursor object.
if(place_meeting(x,y,obj_cursor)){ if(keyboard_check(ord('X'))){ x = obj_cursor.x; y = obj_cursor.y; } }
Posted 19 May 2010 - 12:52 AM
Well then you're putting it in the wrong place or your sprite offsets are weird.This goes in the block's step event. Change obj_cursor to the cursor object.
if(place_meeting(x,y,obj_cursor)){ if(keyboard_check(ord('X'))){ x = obj_cursor.x; y = obj_cursor.y; } }
several ppl have given me this code, however it isn't working as intended, even though it seems as if it should - it's error free, but it does not function right. I placed it in the block's step event, as instructed, and tested it, but it is not working. If i use the arrows to move the cursor over the block, hold down "X", and then move the cursor again using the arrows - still holding X, the cursor does not move the block along with it, like it should.
Posted 19 May 2010 - 06:32 AM
Posted 19 May 2010 - 07:51 AM
Posted 19 May 2010 - 08:24 AM
Posted 19 May 2010 - 01:49 PM
<step event for block object>
if place_meeting(x,y,obj_cursor) && keyboard_check(ord('X'))
drag=1
else drag=0
if drag
{
x+=(keyboard_check(vk_right)-keyboard_check(vk_left))*SPEED //just a smart code to move left/right. SPEED is not the built-in speed, you'll need to define it
y+=(keyboard_check(vk_down)-keyboard_check(vk_up))*SPEED //the same for up'n'down
}
Posted 19 May 2010 - 01:58 PM
Hi
I made with GM8 lite a working example of what i think you want.
http://host-a.net/Gonar/Grab.zip
Hope to help you
Edited by martianblue, 19 May 2010 - 01:59 PM.
Posted 19 May 2010 - 03:43 PM
Edited by Gonar, 19 May 2010 - 03:54 PM.
Posted 19 May 2010 - 05:31 PM
martianblue
try this
http://host-a.net/Gonar/GrabMouse.zip
http://host-a.net/Go...useNoCursor.zip
or
a general mouse grab example http://host-a.net/Go...ragAnObject.gm6
the collision checkings might be tricky, because with mouse, the movement isn't absolute in 2-axis
cu and gl
Posted 19 May 2010 - 07:32 PM
0 members, 0 guests, 0 anonymous users