1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice
  2. NOTICE: We will be applying a Xenforo update on Tuesday 25th of February. This means that from approximately 10:00 to 14:00 BST the forums will be offline (or possibly longer). Sorry for the inconvenience! Official Announcement here.

Alarms/Countdown

Discussion in 'Programming' started by Dioramos, Jun 22, 2019.

  1. Dioramos

    Dioramos Member

    Joined:
    Jun 13, 2019
    Posts:
    33
    I want to add bright effect to background with music sync. Example: when music reaches 5, 7, 15, 19, 33, 144... seconds, instantly spawn white (0.1 alpha) image and slowly "fade out" it. Is there an easy way to do this?
     
  2. TinyGamesLab

    TinyGamesLab Member

    Joined:
    Jun 21, 2018
    Posts:
    147
    You can use audio_sound_get_track_position to get the amount of seconda that the track has been playing.
    I would use it combined with a set of flags (ex f_5 = true) in order to know if the track had reached the desired position and spawn an object with the white image that slowly fades out.
     
  3. Dioramos

    Dioramos Member

    Joined:
    Jun 13, 2019
    Posts:
    33
    Code:
    //Step
    if audio_sound_get_track_position (aMenuMusic) = 8
    {
    global.BR = true;
    }
    I made object with white rectangle sprite and write this to 'Step'. I tried draw, instance_create... But im noob and nothing works properly. Help pls
     
  4. TinyGamesLab

    TinyGamesLab Member

    Joined:
    Jun 21, 2018
    Posts:
    147
    Sure! Try this:

    Creation code:
    Code:
    image_alpha = 0;
    
    //list to hold times where Sprite appears
    Time_list = ds_list_create();
    ds_list_add(Time_list, 5, 7, 15, 19, 33, 144, 99999);
    
    Part = 0;
    
    Step code:
    Code:
    //reduce alpha
    image_alpha = min(image_alpha - 0.1, 0);
    
    //check if part was reached
    if (audio_sound_get_track_position (aMenuMusic) >= Time_list[| Part] )
    {
    Part += 1;
    image_alpha = 1;
    }
    
     
    Phil Strahl likes this.
  5. Dioramos

    Dioramos Member

    Joined:
    Jun 13, 2019
    Posts:
    33
    I added this code to the sprite, but it doesn't appears (i cant see it, but it exists in room). I tried to fix, unsuccessfully...
     

Share This Page