1. Hello Guest! It's with a heavy heart that we must announce the removal of the Legacy GMC Archive. If you wish to save anything from it, now's the time! Please see this topic for more information.
    Dismiss Notice

Drag And Drop [SOLVED] Switching levels/rooms after last frame of cutscene?

Discussion in 'Programming' started by nuyluy, Dec 12, 2018.

  1. nuyluy

    nuyluy Member

    Joined:
    Dec 11, 2018
    Posts:
    10
    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~
     

    Attached Files:

  2. OblivionSkull21

    OblivionSkull21 Member

    Joined:
    Sep 26, 2017
    Posts:
    308
    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)
     
  3. OblivionSkull21

    OblivionSkull21 Member

    Joined:
    Sep 26, 2017
    Posts:
    308
    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);
    }
     
  4. nuyluy

    nuyluy Member

    Joined:
    Dec 11, 2018
    Posts:
    10
    Thank you! I will try that
     
  5. nuyluy

    nuyluy Member

    Joined:
    Dec 11, 2018
    Posts:
    10
    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
     

    Attached Files:

  6. OblivionSkull21

    OblivionSkull21 Member

    Joined:
    Sep 26, 2017
    Posts:
    308
    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.
     
  7. nuyluy

    nuyluy Member

    Joined:
    Dec 11, 2018
    Posts:
    10

    I used your code and it worked!! Thank you a lot for your help! :)
     
    OblivionSkull21 likes this.
  8. OblivionSkull21

    OblivionSkull21 Member

    Joined:
    Sep 26, 2017
    Posts:
    308
    Happy to help!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice