In this thread I will post my Game Maker scripts. I am pretty new to code, but this is something I enjoy to do.
It may only be a simple script but I use it so often, I thought it may be of use to others. Even people who don't know how to code should be able to understand it.
To properly use it you have to have three sub-images for the sprite of the button. The first one should be when the button isn't being hovered over the second one should be when it is. The third one should be when the button is pressed.
CREATE EVENT:
Sets the speed the sprite plays through its sub images to 0. also sets the image the sprite displays at the start to 0.
STEP EVENT:
The first part just checks whether or not the button is touching the mouse cursor. If it is it changes the sub-image to 2. If not it changes the sub-image to 0.
The second parts checks to see if it's being clicked by the left mouse button. If it is it changes the sub-image to 3.
I know it's fairly simple but I thought I'd contribute to the section considering it's pretty bland so far...
It may only be a simple script but I use it so often, I thought it may be of use to others. Even people who don't know how to code should be able to understand it.
To properly use it you have to have three sub-images for the sprite of the button. The first one should be when the button isn't being hovered over the second one should be when it is. The third one should be when the button is pressed.
CREATE EVENT:
Sets the speed the sprite plays through its sub images to 0. also sets the image the sprite displays at the start to 0.
image_speed=0
image_index=0
STEP EVENT:
The first part just checks whether or not the button is touching the mouse cursor. If it is it changes the sub-image to 2. If not it changes the sub-image to 0.
The second parts checks to see if it's being clicked by the left mouse button. If it is it changes the sub-image to 3.
if position_meeting(mouse_x,mouse_y,(self))
{
image_index=1
}
else
{
image_index=0
}
if mouse_check_button_pressed(mb_left)
{
image_index=2
}
I know it's fairly simple but I thought I'd contribute to the section considering it's pretty bland so far...