Pause Music/Sounds When Game is Out of Focus

Discussion in 'Learning Ruby and RGSSx' started by Rikifive, May 4, 2016.

  1. Rikifive

    Rikifive Bringer of Happiness Veteran

    Messages:
    1,442
    Likes Received:
    676
    Location:
    Poland
    First Language:
    Polish
    Primarily Uses:
    Other
    When the game loses focus either by minimalizing or clicking outside the window, the game pauses itself, but the BGM/BGS still plays.


    Is it possible to pause at least BGM when game is out of focus and unpause when getting back to the game? 


    Or make it not pause anything at all ~ game running even in background.


    ~Thanks!
     
    Last edited by a moderator: May 4, 2016
    #1
  2. Zalerinian

    Zalerinian Jack of all Errors Veteran

    Messages:
    4,691
    Likes Received:
    919
    Location:
    The Internet.
    First Language:
    English
    Primarily Uses:
    N/A
    For ace, no. Code execution is stopped when the game is out of focus, so there's really nothing that can be done about it. At least in MV neither updating nor music was paused by default, so it was possible to create a plugin that paused either or both.
     
    #2
    Marsigne and Rikifive like this.
  3. Rikifive

    Rikifive Bringer of Happiness Veteran

    Messages:
    1,442
    Likes Received:
    676
    Location:
    Poland
    First Language:
    Polish
    Primarily Uses:
    Other
    Aww another silly limit.


    Literally, Ace is blocking so many possibilities. . . =/


    (Music-synced minigames - impossibru)


    That's what I get for thinking about doing non-RPG things in RPG focused software...


    (I guess RM is not for me =P)


    Welp, thank you for clarifying. (=
     
    Last edited by a moderator: May 4, 2016
    #3
    Marsigne likes this.
  4. Rikifive

    Rikifive Bringer of Happiness Veteran

    Messages:
    1,442
    Likes Received:
    676
    Location:
    Poland
    First Language:
    Polish
    Primarily Uses:
    Other
    I think I've got an idea


    What would probably solve that problem, would be getting the real time.


    I know it is possible to get the current real time using methods in Time class, but how accurate they are?


    I'd need it pretty accurate ~


    Something like:


    08:31:34'25/60


    HOUR   |    MIN    |   SEC | 1/60 sec (60 FPS - I need to get each frame)


                                                  (or even 1/100 or 1/1000 ~ I could make some maths to convert that)


    Having just


    08:31:34


    HOUR |  MIN  | SEC


    is possible I think, but that way it wouldn't be accurate as one second holds 60 frames and that could cause de-sync.


    That would allow me to implement 'Frame Skip' so even a lag would not cause de-syncs!


    How accurate time can I get?


    I need to take a look on Time Class...
     
    Last edited by a moderator: May 4, 2016
    #4
    Marsigne likes this.
  5. Rikifive

    Rikifive Bringer of Happiness Veteran

    Messages:
    1,442
    Likes Received:
    676
    Location:
    Poland
    First Language:
    Polish
    Primarily Uses:
    Other
    I just found out, that if you'll minimalize Ace by clicking its icon on the task bar - the game is still running ~ it's even updating the input ~ and all of this, when I have a different window active.


    For example, while I'm typing this - the game still runs and I can hear the stuff I'm clicking there, even when I don't even see it.


    So... What kind of sorcery is this? Perhaps it could be possible to do this when doing other things like clicking outside the window? How does that work?
     
    #5

Share This Page