Wait Command

Discussion in 'Learning Javascript' started by Milena, Nov 25, 2015.

  1. Milena

    Milena The woman of many questions Veteran

    Messages:
    1,282
    Likes Received:
    106
    Location:
    Ireland
    First Language:
    Irish
    Primarily Uses:
    N/A
    I am thinking of making a waiting scene in the Gameover scene. For instance, I want to make this image's opacity from 0 to 255. When Gameover hits, I want that image to appear. I was able to do it but the problem is, if I want to do it for like 4 times, it isn't possible with what I do. So, I was thinking of doing something like this in the process:

    1. Gameover screen appears.
    2. An image from 0 to 255 appears.
    3. Wait
    4. Second image from 0 to 255 appears
    5. Wait
    6. third image from 0 to 255 appears
    The reason for the wait is like eventing, I want it to be like a cinematics where I show some stuff, wait for a certain point in time before the second thing appears, until all process happens. I would also like to know how to make it that the gameover will only fade when all these images are processed.
     
    #1
  2. Andar

    Andar Veteran Veteran

    Messages:
    28,333
    Likes Received:
    6,446
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    Most probably your problem is that you don't realise what the wait is from the programmer's side. It's called "wait" in eventing because for the eventer the result looks like a "wait", but the code itself has nothing to do with waiting.


    Basically in eventing, it tells the engine "skip execution of this event for x loops (frames) of the main game loop.


    The game-over sequence is outside the game loop - the game loop has already terminated there because the game has ended.


    Instead of waiting, you need to program the cinematics you want to show in that time - if you create a loop outside the main game loop it will freeze everything in that time
     
    #2
  3. Milena

    Milena The woman of many questions Veteran

    Messages:
    1,282
    Likes Received:
    106
    Location:
    Ireland
    First Language:
    Irish
    Primarily Uses:
    N/A
    My apologies. The last part of your statement is what I am trying to achieve. Because if you program everything in the update method of Scene_Gameover, everything appears together, not consecutively. So I was thinking if there was a rather, method, that would allow us to wait for each of the sprites to appear before the next one do.
     
    #3
  4. Andar

    Andar Veteran Veteran

    Messages:
    28,333
    Likes Received:
    6,446
    Location:
    Germany
    First Language:
    German
    Primarily Uses:
    RMMV
    the computer works linear and processes one command after another.

    That means you either have to make the entire commands sequential and update each step manually befor the nex one, or you need to create your own timed update loop where you assign parts of the commands to parts of the loop time sequence.
     
    #4
    Milena likes this.
  5. izyees

    izyees My Secret Santa Veteran

    Messages:
    243
    Likes Received:
    65
    First Language:
    english
    Do you mean do you want to wait x frames?

    I'm doing something like this

    Code:
    var wait_frame = 60;_.prototype.update = function () {if (wait_time < 0) {wait_time -= 1;} else {// do something here}}
     
    #5

Share This Page