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

GML Visual [SOLVED] Switching levels/rooms after last frame of cutscene?

N

nuyluy

Guest
Hey there!
I made an frame by frame intro animation, which is controlled by button pressing. Every time you press any key, the frame changes one step forward.
Now I want that after the last frame it changes the room/level to the actual gameplay part. How do I do that? The attached file shows my DnD commands so far.
Please help me out~
 

Attachments

Keep track of how many times a key is pressed. I'm not sure if GameMaker has a function for checking if ANY key is pressed, so you might want to set a specific key, like Space.

In the create event of the cutscene:

Code:
count = 0;
In the step event:

Code:
if keyboard_check_pressed(vk_space){
count += 1;
}

if count == 4{ //change this to however many frames you have, or how many times you change the frame
room_goto(room1); //change this to the room you want to go to
}
EDIT:

To check for any key, you would use keyboard_check_pressed(vk_anykey)
 
An alternative to this would be to keep track of the image_index of the cutscene (I'm assuming it's all in one sprite?).
So if your sprite has 5 frames, then the last frame corresponds to image_index = 4 (starts at 0).

So:

Code:
if image_index == 4 && keyboard_check_pressed(vk_anykey){
room_goto(room);
}
 
N

nuyluy

Guest
An alternative to this would be to keep track of the image_index of the cutscene (I'm assuming it's all in one sprite?).
So if your sprite has 5 frames, then the last frame corresponds to image_index = 4 (starts at 0).

So:

Code:
if image_index == 4 && keyboard_check_pressed(vk_anykey){
room_goto(room);
}
So I tried this, but it still loops the cutscene frames instead of switching rooms at the end. I'm sure I used the wrong command somewhere
 

Attachments

So I tried this, but it still loops the cutscene frames instead of switching rooms at the end. I'm sure I used the wrong command somewhere
How many frames is your animation?

Code:
if image_index == 4{
image_speed = 0;

if keyboard_check_pressed(vk_anykey){
room_goto(room1);
instance_destroy(self);
}
}
Be sure to set your sprite to an image_speed of 0 when the last frame is shown so it doesn't start over on its own. You should also destroy the instance now that you no longer need it.
 
N

nuyluy

Guest
How many frames is your animation?

Code:
if image_index == 4{
image_speed = 0;

if keyboard_check_pressed(vk_anykey){
room_goto(room1);
instance_destroy(self);
}
}
Be sure to set your sprite to an image_speed of 0 when the last frame is shown so it doesn't start over on its own. You should also destroy the instance now that you no longer need it.

I used your code and it worked!! Thank you a lot for your help! :)
 
Top