[SOLVED] Need help with point and click movement

S

StrangaStudios

Guest
I'm having a bit of trouble with a click movement system i'm using for an rpg-ish like point and click adventure game. It uses 4 directional movement with the player and I have a method that I want to work but it isn't for some reason.

My question is: is there a way to only create an object on top of another object through gml.

What I have done is made a floor sprite that covers the entire map on where the play CAN move. I want to be able to create a move point when I click anywhere on this floor sprite but only on the floor sprite and no where else. I hope this makes sense

Here is an image to try and help explain:
 
A

Aura

Guest
You could possibly use position_meeting() to ensure that the mouse is over the floor instance before a move point instance is created.

Code:
if (mouse_check_button_pressed(mb_left)) {
   if (position_meeting(mouse_x, mouse_y, obj_Floor)) {
      instance_create(mouse_x, mouse_y, obj_MovePoint);
   }
}
 
S

StrangaStudios

Guest
You could possibly use position_meeting() to ensure that the mouse is over the floor instance before a move point instance is created.

Code:
if (mouse_check_button_pressed(mb_left)) {
   if (position_meeting(mouse_x, mouse_y, obj_Floor)) {
      instance_create(mouse_x, mouse_y, obj_MovePoint);
   }
}
Thank you so much worked perfectly!
 
K

Kevin Alexander

Guest
Excuse me, im a student practicing GML and i wish to use point and click for my current dungeon crawler that i will turn in as a project. What exactly is the object obj_MovePoint in your code
 
S

StrangaStudios

Guest
Excuse me, im a student practicing GML and i wish to use point and click for my current dungeon crawler that i will turn in as a project. What exactly is the object obj_MovePoint in your code
Hey Kevin,

The move point was an object I created as like a destination goal. If you think of a GPS you set a destination and then you drive or walk to that point. Same idea, except the character moves on its own.

I will upload the code I use tomorrow because it is late here or pm me.
 
Top