Posted 09 June 2012 - 09:34 PM
Posted 09 June 2012 - 09:47 PM
if (mouse_check_button_pressed(mb_left))If you need codes for any other mouse buttons, I guess you can figure them out easily. (Otherwise, just search the GM manual for "mouse")
Use the two variables mouse_x and mouse_y when setting the position of the instance to be created. This will create it at the mouse's position.
Posted 09 June 2012 - 11:05 PM
Posted 09 June 2012 - 11:19 PM
If you have an object which shoots things, e.g. a cannon, you can make its shots travel to the mouse's position using this:
var ID; ID = instance_create(x, y, obj_shot); //or however your shot instances are created. Make sure you add the "ID =" part, though! ID.direction = point_direction(x, y, mouse_x, mouse_y); //using a dot after ID will refer to ID's variables (the variables of the shot) instead of my the cannon's. ID.speed = whatever speed you want the shot to travel at;
Edited by TsukaYuriko, 09 June 2012 - 11:20 PM.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users