Touch/click and drag path movement

K

KevlarGolem

Guest
I'm trying to find a tutorial on how to allow the player to move objects by touching/clicking them, then dragging a path to the desired destination (as seen in iOS Flight Control or Harbor Master).

I've done searches for this, but I'm finding movement tutorials not covering this style, or I'm finding path tutorials that are aimed at creating set patrol paths that the player can't actively create.

I'd prefer drag and drop programming if possible, or if code is required, the more my hand is held the better. My programming skills are about as amateur as it gets.
 

Tthecreator

Your Creator!
There can't be a tutorial for everything.
There are just so may different mechanics one could want to implement that it becomes impossible to make a tutorial for every single possibility.
If you already searched for this with your "mad google skillz" then I properly won't find it either.

What you want is not that hard. I see you're a beginner with game maker, and I would recommend figuring out how to do the following things:
-get the position of the mouse
-get when the mouse is pressed
-get when the mouse hovers over an object
-how to drag the mouse, which is probably the hardest, as you will need to "remember" you pressed the mouse when dragging it, and also make sure that other objects can't be dragged when that single object is being dragged.
 
G

Gre_Lor12

Guest
To start you off, you should use this as a base code. This will check for the mouse pos, and also then check if its been clicked on top of the object:

CREATE EVENT

clicked = false //Checks to see if I have been clicked


STEP EVENT

//Check to see if the mouse if over me
if (instance_position(mouse_x,mouse_y, this_object) )
if (mouse_check_button_pressed(mb_left) )
if (clicked == false)
{
//Set to true to recognise that it has actully been clicked
clicked == true
}
else
{
var path = pth1

//path_start(path, speed, endaction, absolute);
path_start(pth1, 0, path_action_reverse, 0);
}


I haven't done the path programming as it is dependent on how you want the path (like if you wanted it to begin on the path right away or not).

Hope this helps ;)
 
Top