• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Making object move when mouse hovers over it

S

Sho0k

Guest
Hey guys!

I'm quite a beginner at programming so I'm kind of a noob with all this Orz.

Basically, I'm working on a point and click style game and I want to create this effect that makes an object jiggle (rotate left then right slightly) when the mouse hovers over it, does anyone know what the code for this would be?

I will greatly appreciate your help!

Thanks!
 

Simon Gust

Member
try this code in the step event of an object that is not the object you want to jiggle.
OBJECT being the object index (name in resource tree) of the desired jiggling object.

Code:
var instance_mouse = instance_place(mouse_x, mouse_y, OBJECT);
if (instance_mouse != noone)
{
 var timer = current_time / 50;
 instance_mouse.image_angle = sin(timer) * 15;
}
 
S

Sho0k

Guest
try this code in the step event of an object that is not the object you want to jiggle.
OBJECT being the object index (name in resource tree) of the desired jiggling object.

Code:
var instance_mouse = instance_place(mouse_x, mouse_y, OBJECT);
if (instance_mouse != noone)
{
 var timer = current_time / 50;
 instance_mouse.image_angle = sin(timer) * 15;
}
Thank you very much!! I managed to achieve the jiggle with that piece of code! However, I had to change instance_place to instance_position instead.
 
Top