Feature Request: Pause on unfocus apart from preview.

0 favourites
  • 12 posts
  • I'm wondering why the project setting "Pause on unfocus" is specified as only available during preview? I'd like to have that feature as part of my exported NW.JS app.

    Maybe there's another way of achieving the same thing? Any way to do that by editing the code itself? I think I found the relevant part in the preview.js script but I have no idea how to get it into my exported game's data.

  • There was a discussion about this before and (if I remember correctly) there's a browser limitation that prevents the HTML5 apps from doing that kind of stuff. Someone correct me if I'm wrong.

  • I worked on the problem today and I got the feature working by simply changing the part of the code that disables it when not in preview mode (in preview.js). But I'm still left wondering if there's a good reason why it was disabled in the first place. Can't be that it doesn't work, glerikud, since it does now (for NW.JS at least).

  • Thanks for the heads up, now I know it's possible. Hopefully someone will clear it up why it's not included.

  • Ashley could you explain why the feature was restricted? I'll be releasing my game soon and I don't want to keep that in if it causes known issues.

  • It's designed to stop the game running while you go back to edit it further in Construct 2. Why would you want that after publishing?

  • It's designed to stop the game running while you go back to edit it further in Construct 2. Why would you want that after publishing?

    While I'm fine without this feature, I can see situations when it becomes useful. For ex. the player plays the game and someone just texted her on Facebook and she wants to reply. In this case the player won't have to find an implemented pause feature (if there's any).

  • It's designed to stop the game running while you go back to edit it further in Construct 2. Why would you want that after publishing?

    Because people tend to multi-task on computers and so its nice to have the game automatically pause events and especially sound when one clicks on a different window.

    Thanks for the info.

  • > It's designed to stop the game running while you go back to edit it further in Construct 2. Why would you want that after publishing?

    >

    Because people tend to multi-task on computers and so its nice to have the game automatically pause events and especially sound when one clicks on a different window.

    Thanks for the info.

    What about timescaling?

    Check if the game is out of focus, when it is just set it to 0.

    The browser plugin has all the conditions you need for that.

  • >

    > > It's designed to stop the game running while you go back to edit it further in Construct 2. Why would you want that after publishing?

    > >

    >

    > Because people tend to multi-task on computers and so its nice to have the game automatically pause events and especially sound when one clicks on a different window.

    >

    > Thanks for the info.

    >

    What about timescaling?

    Check if the game is out of focus, when it is just set it to 0.

    The browser plugin has all the conditions you need for that.

    I tried that but it doesn't seem to work when NW.JS is used as the ersatz browser. Unless I just had it set up wrong.

    Anyway modifying the runtime code myself worked, its just not the most convenient way of going about this.

  • I tried that but it doesn't seem to work when NW.JS is used as the browser. Unless I just had it set up wrong.

    If that is indeed the case you should file a bug report with the all the requirements right now! (capx + how to reproduce)

    Anyway modifying the runtime code myself worked, its just not the most convenient way of going about this.

    I like to hear that, I modified a fair amount of C2 files too already.

    What exactly did you change to get it back working like was used to before?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • >

    > What exactly did you change to get it back working like was used to before?

    >

    >

    This is the code that was already in preview.js:

    // Pause on blur (unfocus)

    if (this.pauseOnBlur && !this.isMobile)

    {

    jQuery(window).focus(function ()

    {

    self["setSuspended"](false);

    });

    jQuery(window).blur(function ()

    {

    self["setSuspended"](true);

    });

    }

    I simply moved it outside of the part that made it only activate when in preview mode.

    But yeah, I'll try to get it working again with the browser plugin instead.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)