• 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!

exit button

N

nessabby1

Guest
I have an exit button. when the player mouse left presses the button id like a small window to pop up that contains my sprite. well baically i want the sprite image to pop up.because i have the yes and no onto the image itself. i dont want to draw it.. i just want the image to pop up if the player clicks the exit button. Is that possible
 
N

nessabby1

Guest
I have an exit button. when the player mouse left presses the button id like a small window to pop up that contains my sprite. well baically i want the sprite image to pop up.because i have the yes and no onto the image itself. i dont want to draw it.. i just want the image to pop up if the player clicks the exit button. Is that possible
when i say "draw" i mean, i dont want to draw the yes or no because i already have that onto the image itelf
 

jazzzar

Member
hmm, maybe create them in the middle of the room? make the yes and no two different object, and on the release of the exit button you just create these two objects in the middle of the screen
 
N

nessabby1

Guest
hmm, maybe create them in the middle of the room? make the yes and no two different object, and on the release of the exit button you just create these two objects in the middle of the screen
I dont think you understand, I have a sprite image that is a box shape and in it reads" Do you really want to exit" and then the Yes or No in the image itself. I just wanted to know if there was a way to simplypop up that entire sprite once the player clicks the exit button.
 

jazzzar

Member
I dont think you understand, I have a sprite image that is a box shape and in it reads" Do you really want to exit" and then the Yes or No in the image itself. I just wanted to know if there was a way to simplypop up that entire sprite once the player clicks the exit button.
make that sprite an object and and create it than, or draw it, there is no other way other than doing that :/
 

Warspite2

Member
Why not draw it? What about a mouse left pressed event that sets a variable, for example press_button = 1 when pressed on exit_button. Then in draw event...if press_button = 1 then draw_sprite (exit_button.x, exit_button.y, your_sprite). Then you can add in global left pressed assuming your button is 64x32 and in location x 64, y 64...if mouse_x >= 64 && mouse_x <= 128 && mouse_y >= 64 && mouse_y <= 96 then do whatever it is you want. Like this you can even have the button light up when hovering over it by using a mouse enter and checking press_button = 1 then using draw_sprite_ext.
 
N

nessabby1

Guest
Why not draw it? What about a mouse left pressed event that sets a variable, for example press_button = 1 when pressed on exit_button. Then in draw event...if press_button = 1 then draw_sprite (exit_button.x, exit_button.y, your_sprite). Then you can add in global left pressed assuming your button is 64x32 and in location x 64, y 64...if mouse_x >= 64 && mouse_x <= 128 && mouse_y >= 64 && mouse_y <= 96 then do whatever it is you want. Like this you can even have the button light up when hovering over it by using a mouse enter and checking press_button = 1 then using draw_sprite_ext.
Thanks i understand what you are saying, but this didnot work. it just disappeared my exit button
 

TheouAegis

Member
So the sprite contains the words "Yes" and "No" already and looks something like this:

XXXXXXXXXXXXX
X-YES-XX-NO-X
XXXXXXXXXXXXX


Set the origin of the sprite in its center. Draw the sprite at (room_width/2,room_height/2) so it's in the center of the room.

Open the sprite in the sprite editor. Find out the bounds of the Yes and the bounds of the No areas. For example, Yes might be (48,16) to (96,32) and No might be (128,16) to (160,32). Let's say the center of the sprite is at (102,24). Subtract the bounds from the center of the sprite and you have the four offsets for each button you'll need to compare with the mouse position.

When the sprite is being drawn on the screen, check if the mouse is pressed. If it is, check the coordinates of the mouse against the bounds.

if mouse_check_button_pressed(mb_left)
{
xx = mouse_x - room_width/2;
yy = mouse_y - room_height/2;
if median(xx, Yes_left_bound, Yes_right_bound) == xx
&& median(yy, Yes_top_bound, Yes_bottom_bound) == yy
// Treat it as though Yes was clicked

if median(xx, No_left_bound, No_right_bound) == xx
&& median(yy, No_top_bound, No_bottom_bound) == yy
// Treat it as though No was clicked
}
 
Top