GMS 2 Animation playing AFTER the sound file

Discussion in 'Programming' started by Cartoonicus, Sep 11, 2019.

  1. Cartoonicus

    Cartoonicus Member

    Sep 11, 2019
    This is the most bizarre situation.

    I have an animation I want to play as long as a certain sound file is playing. Let me see if I can explain my programming in D&D.

    Create Event:
    Assign Variable: radio_channel = 0
    Set Animation Speed = 0
    Set Sprite: anim_radio = 1

    Step Event:
    If audio is playing: snd_radio0
    Set Animation Speed = 1
    Set Sprite: anim_radio = 1
    Set Animation Speed = 0
    Set Sprite: anim_radio = 1

    Left Released:
    If Variable: radio_channel is = 0
    Play Audio: snd_radio0

    (The reason I'm doing this in variables is because I want to end up with multiple sound files that will play in order)

    So you see, when the player clicks on a button, if the variable: "radio_channel" is zero, the audio file "snd_radio0" should play from start to finish. Then in the step event, if the audio file "snd_radio0" is playing the animation: "anim_radio" should play and loop as long as "snd_radio0" is playing, then stop. However, instead the animation waits until the audio file has completely finished playing, to start, then loops forever.

    What the heck am I missing?

    What order does a step event happen in relation to a mouse click. I have an audio file that playson a mouse release and an animation that's supposed to play when the step event asks if the Audio file is playing but instead the entire sound file plays and THEN the animation starts.
  2. TsukaYuriko

    TsukaYuriko Q&A Spawn Camper Forum Staff Moderator

    Apr 21, 2016
    (I merged your reply to another topic into this one - please don't resurrect years old topics and please keep your own questions contained in your own topics.)

    The order in which events happen is partially documented on the Object Events manual page. The relation between Step and Mouse events is not outlined there, so it is undefined and may take on any shape or form. You can therefore not rely on it.

    Make sure you're properly nesting your code. An if statement, by default, only encapsulates the following action. If you want multiple actions to depend on it, they need to be in a block.

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