U
User
Guest
I want to make a button. It will be animated button.
When user do nothing - button look like simple image.
When user move mouse on button - it will be animation "backlighting".
When user move mouse out button - it will be animation "fogging".
All animations must stop on last frame.
I have 3 sprites.
Sprite 1 - "button_normal_sprite". This is a button when no one touches it. Initial button state.
Sprite 2 - "button_mouse_on_sprite". This is a button when user move mouse on button.
Sprite 3 - "button_mouse_leave_sprite". This is a button when user leave mouse on button.
I create a object, load a "button_normal_sprite" and write a code.
Events->Step
What code should I write?
PS
I dont use mouse enter-leave events. In this case they can be lagging (a lot of videos on youtube "gms2+create buttons" where people show it).
When user do nothing - button look like simple image.
When user move mouse on button - it will be animation "backlighting".
When user move mouse out button - it will be animation "fogging".
All animations must stop on last frame.
I have 3 sprites.
Sprite 1 - "button_normal_sprite". This is a button when no one touches it. Initial button state.
Sprite 2 - "button_mouse_on_sprite". This is a button when user move mouse on button.
Sprite 3 - "button_mouse_leave_sprite". This is a button when user leave mouse on button.
I create a object, load a "button_normal_sprite" and write a code.
Events->Step
Code:
//Mouse on button - play animation "backlighting".
//It work good
if (instance_position(mouse_x,mouse_y,id)>0)
{
sprite_index=button_mouse_on_sprite;
if (image_index>4) image_speed = 0; //Stop on last(?) frame
}
//Mouse out of button - play animation "fogging".
//Problem here...
/*
if (instance_position(mouse_x,mouse_y,id)<0)
{
sprite_index=button_mouse_leave_sprite;
if (image_index>4) image_speed = 0;
}
*/
PS
I dont use mouse enter-leave events. In this case they can be lagging (a lot of videos on youtube "gms2+create buttons" where people show it).