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

Legacy GM How to click anywhere so that it goes to the next room?

A

Artwark

Guest
So I'm making this game on mobile and I've tried the following inorder to go to the next room.


obj_gametitle

Left Mouse button event
global.title = virtual_key_add(x,y,1024,728,mouse_check_button(mb_left));
virtual_key_show(global.title);
room_goto(rm_game);

If I click it, it doesn't go to the next room that is rm_game....any ideas how I can fix this. Keep in mind that I am doing it for mobile as earlier before adding the virtual key, it worked when using any key event

Then I noticed that there's a function called device_mouse_check_button so then I changed it and tried this.

if device_mouse_check_button(0,mb_left) == true
{
room_goto(rm_game);
}

In the compile section, it shows that it works but it still won't go to the next room.....how do I fix this?
 

TehCupcakes

Member
You are using the wrong event. It should be Global Left Mouse. (Global meaning you can click anywhere on the screen, not just on an instance of obj_gametitle.) Having a virtual key cover the entire screen also sounds like a terrible idea... You probably want some way to detect if a virtual key is pressed, and if so, do whatever that key does; else, room_goto(rm_game). (All this within the Global Left Mouse event... Or you could possibly spread them out in different events and use some variables, at your discretion.)
 
A

Artwark

Guest
You are using the wrong event. It should be Global Left Mouse. (Global meaning you can click anywhere on the screen, not just on an instance of obj_gametitle.) Having a virtual key cover the entire screen also sounds like a terrible idea... You probably want some way to detect if a virtual key is pressed, and if so, do whatever that key does; else, room_goto(rm_game). (All this within the Global Left Mouse event... Or you could possibly spread them out in different events and use some variables, at your discretion.)
Ok so now I did this

Global Left mouse button event

global.title = virtual_key_add(x,y,64,64, mb_left);
room_goto(rm_game);

And when I click it, it still doesn't show the next room.
 

FredFredrickson

Artist, designer, & developer
GMC Elder
Why are you adding a virtual key?

Just check the state of the mouse:
Code:
if (mouse_check_button_released(mb_left)){
room_goto(rm_game);
}
You can either add that code to a Step event, or check the button through events (Add Event > Mouse > Global Mouse > Global left released) and just use the room changing code:
Code:
room_goto(rm_game);
 
A

Artwark

Guest
Why are you adding a virtual key?

Just check the state of the mouse:
Code:
if (mouse_check_button_released(mb_left)){
room_goto(rm_game);
}
You can either add that code to a Step event, or check the button through events (Add Event > Mouse > Global Mouse > Global left released) and just use the room changing code:
Code:
room_goto(rm_game);
I tried them both but now, whenever I click the left mouse button and release it, it always goes to the title screen and starts the game. This is bad because I set virtual keys in the rm_game and those are meant for the mobile version so I can't click those virtual keys in that case.
 

FredFredrickson

Artist, designer, & developer
GMC Elder
I tried them both but now, whenever I click the left mouse button and release it, it always goes to the title screen and starts the game. This is bad because I set virtual keys in the rm_game and those are meant for the mobile version so I can't click those virtual keys in that case.
But... you said that you wanted the game to go to the next room when you clicked anywhere. You didn't mention any other buttons.

I still don't see why you would use virtual keys for this, though. Do you handle all the buttons in one object?
 
A

Artwark

Guest
Ok so it goes like this.

I made a title screen which is the first room that shows up. The next room is where the main gameplay takes place. You simply have directional arrows for movement and a spacebar for shooting.

To make this in mobile, I added virtual keys where the up, left and right are for the movement and the red bar at the far right is for shooting. I managed to make these actions work as intended.

So seeing as how everything in mobile relies on the touch mechanic, I need to make it so that when you touch the title screen, you start the game and that touching anywhere in the rm_game does not take you to the title screen again nor does it pause to the title screen and then starts the game.

So I want it so that if the player touches anywhere in the title screen, the player can start the game. If that is not possible to do, then I have to make it touch at the center alone I guess......so is there a way to do this?
 
Top