Waog's Recent Forum Activity

  • Are there any methods I could call from Javascript manually, to inform construct about the visibility change?

    I found it out myself. Use this code to trigger the supend and resume manually:

    function simulatePageVisibilityApiHide() {
        document.hidden = true;
        document.mozHidden = true;
        document.webkitHidden = true;
        document.msHidden = true;
        var event = new Event('visibilitychange');
        document.dispatchEvent(event);
    }
    
    function simulatePageVisibilityApiUnhide() {
        document.hidden = false;
        document.mozHidden = false;
        document.webkitHidden = false;
        document.msHidden = false;
        var event = new Event('visibilitychange');
        document.dispatchEvent(event);
    }[/code:1ys2unqy]
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Okay, I could solve the problem on my own, after discovering this in another topic:

    Closing as won't fix: the problem is with the browser, not C2.

    In Chrome for iOS, it correctly triggers 'On suspend' and 'On resume' when switching tabs, but not when returning to the home screen and going back (which Safari does correctly). Old Android stock browsers simply don't support the Page Visibility API which is the way the browser tells C2 if the page has been hidden, so it can't be supported. It should work in Chrome for Android though.

    I solved the problem by adding this code snippet to the exported project:

    document.addEventListener("deviceready", function() {	
        document.addEventListener("pause", simulatePageVisibilityApiHide, false);
        document.addEventListener("resume", simulatePageVisibilityApiUnhide, false);
    }, false);
    
    function simulatePageVisibilityApiHide() {
        document.hidden = true;
        document.mozHidden = true;
        document.webkitHidden = true;
        document.msHidden = true;
        var event = new Event('visibilitychange');
        document.dispatchEvent(event);
    }
    
    function simulatePageVisibilityApiUnhide() {
        document.hidden = false;
        document.mozHidden = false;
        document.webkitHidden = false;
        document.msHidden = false;
        var event = new Event('visibilitychange');
        document.dispatchEvent(event);
    }[/code:1n2qqp0m]
  • Are there any methods I could call from Javascript manually, to inform construct about the visibility change?

  • Probably related:

    The Browser Objects "On Suspended" and "On Resumed" events also don't trigger when sending the app to the background.

    And I had the same problem when using Intel XDK before.

  • Hi,

    when I export my game to android and send the app to the background the sound and music continues playing. It even continues playing when turning of the screen of the device.

    I exported the game with cordova (no media plugin or crosswalk).

    The "Play in Background" property of the Audio object is activated and works fine in the browser.

    How do I stop the sound in the exported version?

  • using the sounds instead of music folder worked for me too.

    I used cordova. When I added the Media or Crosswalk plugin it stopped working... so stick with plain cordova and android platform.

    Why would one use the music folder at all? are there any advantages over the sound folder?

  • I have the same problem almost one year later.

    Newest Version of Chrome works fine. Newest Version of FF (default settings) blocks the new windows with the inbuilt popup blocker.

    Also the Construct documentation states

    [quote:2huv8mv1]Open URL in new window

    Navigate to a given URL in a new window (or tab if the browser settings override). This continues to run the HTML5 game in the old window or tab.

    How to change the default way to open the URL to "tab" instead of "window"? I doesn't need to work for customized browser settings, but should at least work for the default settings.

  • Thx, but I don't understand what you mean by "skin". Could you explain that a little bit deeper?

    I found this topic about different player skins. But the answer there encourages exactly my current approach, i.e. having one sprite with 12 different animations and select them by string concatenation.

    No, I didn't follow this tutorial, because I only had the free licence, when learning construct (i.e. the sprites where not available). I just browsed it, but couldn't see anything about your skin approach.

  • Hi,

    I'm creating a game where my main character has two directions of animations, like in the super mario games:

    • Dimension A: stand, run, jump, attack
    • Dimension B: lowLife, medLife, highLife

    So in this example I have 4*3 = 12 different animations, which my character must be able to play.

    Currently I realized this the following way, which I'm not very happy about:

    • I have one Sprite with 12 different animations: stand_1, stand_2, stand_3, run_1, run_2, etc.
    • I have some variables in my event sheets representing my state.
    • depending on my state variables I do some string concatenations to determine the next animation.

    Are there any better ways to accomplish the same result?

  • Since images are loaded layout-by-layout my game "freezes" for some seconds, when switching layouts.

    Is there a way to show the loading progress, or to enforce loading all images on game-start?

Waog's avatar

Waog

Member since 3 Aug, 2014

None one is following Waog yet!

Connect with Waog

Trophy Case

  • 10-Year Club
  • Email Verified

Progress

11/44
How to earn trophies