Windows attach an object to the screen (Button Menu)

S

ShadowLenz

Guest
hi! i'm using game maker 1.4
i'm making an RPG and i design a button menu, i want to put it to a screen corner. it's not a simple frame, has an animation and other one when the mouse is over him.
I know you can use the views of the rooms but I'm not very good at working with that. (the character has already assigned one of the views)
 

TheouAegis

Member
What code do you already have in place for the button menu?..The view is updated in the Predraw event, so you need to set the button coordinates to view_xview and view_yview during the BEGIN DRAW event.
 

Yal

šŸ§ *penguin noises*
GMC Elder
You can draw based on the view using the view_* arrays:
GML:
draw_sprite(sprite_index,image_index,view_xview,view_yview)
 
S

ShadowLenz

Guest
You can draw based on the view using the view_* arrays:
GML:
draw_sprite(sprite_index,image_index,view_xview,view_yview)
i did that already but it only draw one single image and not the whole animation, when i put the mouse o him does not play anything
 

woods

Member
the image speed at the start is 0, when the mouse is over the button plays the animation
plays the animation at speed of zero?
you need to set the image_speed when the mouse is hovering over the image
 

TheouAegis

Member
You said it only draws one image, so it's not playing the animation.

Is your (pseudo) code like:

if mouseOver image_speed = 1
else image_speed = 0

?
Or

If mouseEnter image_speed = 1

(Animation End) image_speed = 0

?
 
S

ShadowLenz

Guest
plays the animation at speed of zero?
you need to set the image_speed when the mouse is hovering over the image
you get me wrong, the button has no speed animation at the start, so is image_speed = 0
when mouse is over him image_speed sets to a number = 1
when the mouse leaves: image_speed = 0 image_index = 0;
 
S

ShadowLenz

Guest
You said it only draws one image, so it's not playing the animation.

Is your (pseudo) code like:

if mouseOver image_speed = 1
else image_speed = 0

?
Or

If mouseEnter image_speed = 1

(Animation End) image_speed = 0

?
goes like this

object_button_menu

Create event:
image_speed = 0;
image_index = 0;

Mouse enter:
(script)
image_speed = 1;
if (image_index == 0) image_index++;

Mouse leave
image_speed = 0;
image_index = 0;

Draw event:
(script)
draw_sprite (button_menu_spr,image_index,view_xview+650, view_yview+50);
 

TheouAegis

Member
You need a sprite in order to use image_index and image_speed.

So you'll need to use a custom variable instead of image_speed. Or assign it the sprite.
 
S

ShadowLenz

Guest
You need a sprite in order to use image_index and image_speed.

So you'll need to use a custom variable instead of image_speed. Or assign it the sprite.
so like imgspeed = image_speed and then like in the creation code?
 

TheouAegis

Member
Oh sorry, typo, kinda. I meant to say you'll need a custom variable instead of image_index. You can use image_speed, but you will need to manually increase the value of whatever variable you use in place of image_index manually.

E.g.,
Code:
img += image_speed / sprite_get_number(button_menu_spr);
if img >= sprite_get_number(button_menu_spr) {
    image_speed = 0;
    img = 0;
}
draw_sprite(button_menu_spr, img, view_xview, view_yview);
 
S

ShadowLenz

Guest
Oh sorry, typo, kinda. I meant to say you'll need a custom variable instead of image_index. You can use image_speed, but you will need to manually increase the value of whatever variable you use in place of image_index manually.

E.g.,
Code:
img += image_speed / sprite_get_number(button_menu_spr);
if img >= sprite_get_number(button_menu_spr) {
    image_speed = 0;
    img = 0;
}
draw_sprite(button_menu_spr, img, view_xview, view_yview);
the code need to be in create event or the step event?
 

TheouAegis

Member
You'll need to set the variable to 0 in the Create Event. You can increment the variable in any event that runs repeatedly, such as Step, End Step, Begin Draw, or in the normal Draw event.
 
Top