Login | Register

Famous script_hover

July 18, 2006, 15:15 by Calle
[loading]
-->
Although most of us have capacity to create our own script_hover Marks’ script_hover is the most famous, and I always it, in examples, I see other people use – because it is easy and fast to implement. It never let you down.

<div style="clear: both;"> if position_meeting(mouse_x,mouse_y,self) {
image_single = 1
}
if position_meeting(mouse_x,mouse_y,self)
&& (mouse_check_button(mb_left)==true) {
image_single = 2
}
if !(position_meeting(mouse_x,mouse_y,self)) {
image_single = 0
}
</div>

This script is used for a button with three subimages, one when the mouse has no contact with the button, one when the button is pressed and one when the mouse is hovering over the button. The position_meeting function is ideal to define what the situation is.

As this script is professionally written it can be applied to any button, without change (unprofessionally scripts are typically very specific for certain situations). This works because of the “self”. Self returns the ID of the instance of calls it, so it could easily be replaced by id.

This is something every beginner should think at: create solutions which are applicable for as many situations as possible.

Comments

Loading comments... [loading]
.
Users logged in:

game maker articles, game maker examples, game maker tutorials, gmtutorials, game maker questions and answers, game maker crash course, how to create games