M
maranpis
Guest
Hello guys:
I'm working on point and click movements. I have a box that moves where the mouse is clicking, but I don't know how to add collisions if I can't divide my speed to hspd and vspd.I created two objects
1. a box ,obj_enemy_CL3_PointAClick
2. the crosshair obj_crosshair
this the box codes:
create event: spd=16; //setting speed
step event:
Global left pressed mouse event
And this is the crosshair codes:
Step event
Global left pressed mouse event
Does anyone know where i should put the x and y collision and how can i set it if in this case i don't have vspd and hspd? or maybe how can i set vspd and hspd in this code?
thanks !
I'm working on point and click movements. I have a box that moves where the mouse is clicking, but I don't know how to add collisions if I can't divide my speed to hspd and vspd.I created two objects
1. a box ,obj_enemy_CL3_PointAClick
2. the crosshair obj_crosshair
this the box codes:
create event: spd=16; //setting speed
step event:
Code:
if instance_exists(obj_crosshair) // if the crosshair exists the box moves towards the crosshair
{
var mouse_distance = point_distance(x,y,obj_crosshair.x,obj_crosshair.y) ;
move_towards_point(obj_crosshair.x,obj_crosshair.y,min(spd,mouse_distance)) ;
}
Code:
if (!instance_exists(obj_crosshair))
{
instance_create_depth(mouse_x,mouse_y,0,obj_crosshair) ;
}
Step event
Code:
if (place_meeting(x,y,obj_enemy_CL3_PointAClick))
{
image_alpha=0;
}
else
{
image_alpha=1;
}
Code:
x=mouse_x;
y=mouse_y;
Does anyone know where i should put the x and y collision and how can i set it if in this case i don't have vspd and hspd? or maybe how can i set vspd and hspd in this code?
thanks !