The Big NW.js Roundup - News & Tips

From the Asset Store
Big Must Jump
$2 USD
60% off
Jump over the small square and avoid hitting it as long as you can!
  • No problem, bug report is here:

    github.com/Scirra/Construct-3-bugs/issues/4109

    Not sure if the route of this going to end up being construct or chromium, but something very odd is that it does work when you right-click on the project name and select preview project. However if you preview the project using the dropdown shortcut on the toolbar it doesn't work. It also doesn't work when you export as nwjs project.

    (EDIT: Apologies for my first comment on that bug being somewhat emotional. I took a week off from my full time job to do gamedev, something that is very rare opportunity. Everything was working perfectly and now I updated C3 & nwjs and the resulting issues have kind of ruined my week off)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No problem, bug report is here:

    https://github.com/Scirra/Construct-3-bugs/issues/4109

    Not sure if the route of this going to end up being construct or chromium, but something very odd is that it does work when you right-click on the project name and select preview project. However if you preview the project using the dropdown shortcut on the toolbar it doesn't work. It also doesn't work when you export as nwjs project.

    Outside of NWjs this is expected behavior. As Ashley said, it requires a user gesture for obvious reasons. If you however experience this in NWjs, that's a bug. NWjs should by default allow requesting fullscreen without a gesture or any additional permissions.

    Do you experience this in NWjs or does it work as expected there?

  • It definitely doesn't work in nwjs, I use Construct on desktop via nwjs and I tested exporting multiple projects ot nwjs. None of my projects work. I also just recreated a very simple project in nwjs and tested - it didn't work

  • It definitely doesn't work in nwjs, I use Construct on desktop via nwjs and I tested exporting multiple projects ot nwjs. None of my projects work. I also just recreated a very simple project in nwjs and tested - it didn't work

    There seems to be a strange bug with NWjs v0.46.3+ and performing basic browser actions. This affects more than just requesting fullscreen.

    I've reported it here: github.com/nwjs/nw.js/issues/7542

  • SecondDimension

    I too have struggled with developing for PC with C3 + NWjs. Here's what I've learned about fullscreen that is not immediately obvious without some digging.

    There are 2 ways to do full screen with NWjs (that game devs care about).

    1) HTML5 API, which I believe C3 implements into it's "Request Fullscreen" action from the "Browser" object, which allows you to fullscreen a specific element and it's children within a web page. It comes along with all the security/user safety baggage.

    2)The NWjs Window Object, which C3 does NOT implement into it's "NWjs" object, which I believe they should, but they haven't. This way uses the operating system function to fullscreen the entire window. No baggage with this one, it should work 100% of the time.

    So in your bug ticket, since you're referring to the Browser request full screen action, Ashely is right, he can't do anything about how the browser implements the HTML5 API. Maybe NWjs made a change, or maybe chromium made a change, who knows.

    But to solve your problem, what you need is the NWjs Window functions to enter and leave fullscreen. It's not ideal, but there's still a way to access it even though C3 doesn't have it built in. Keep in mind, NWjs is still running in the background so you can still control it with javascript.

    There's just 2 lines of code you need to get access to the NWjs window object.

    var ngui = require('nw.gui');
    var nwin = ngui.Window.get();
    

    Then another 2 to enter or leave fullscreen.

    nwin.enterFullscreen();
    nwin.leaveFullscreen();
    

    So insert that code into an event sheet, with an inline script, where ever you want it triggered. The image below is from the KiwiStory sample project that I slightly modified.

    To configure how the fullscreen works (letterbox scale, etc), set that in "Fullscreen mode" in the project properties under "Display"

    I hope that helps.

  • Fib will that script run successfully even if the user doesn't do an action? i.e. can you automatically make the game fullscreen?

  • Fib will that script run successfully even if the user doesn't do an action? i.e. can you automatically make the game fullscreen?

    Just tested it, it works for exports, but it doesn't work when previewing (I'm working with the desktop NWjs version of C3).

  • I just noticed that previewing in C3 NWjs window, doesn't register as a NWjs export on the platformInfo plugin, so that's probably why the fullscreen is not working either.

  • > Fib will that script run successfully even if the user doesn't do an action? i.e. can you automatically make the game fullscreen?

    Just tested it, it works for exports, but it doesn't work when previewing (I'm working with the desktop NWjs version of C3).

    Correct. It will only work for exported games, not during preview.

  • Fib will that script run successfully even if the user doesn't do an action? i.e. can you automatically make the game fullscreen?

    Yes it will work anywhere. No user input required.

  • Fib hey thank you so much for taking the time to write that up, seems to be just what I need. I can live without it during preview if I know it will work when exporting. I will give it a go in my project today. Hopefully this will help anyone else with these issues too!

  • My initial attempt at that solution didn't work, but I've got it sorted now. My issue was that worker mode was enabled, which isn't compatible with scripting. Having turned off worker mode and exported then it functions as expected, thanks again Fib

  • These scripts will probably work fine but I think it would still be better to wait for the core issue to be fixed. From my experience any NWjs version before v0.46.3 worked fine.

    If it doesn't, please give me a heads up.

  • These scripts will probably work fine but I think it would still be better to wait for the core issue to be fixed. From my experience any NWjs version before v0.46.3 worked fine.

    If it doesn't, please give me a heads up.

    There may be a bug in the HTML5 API fullscreen request, I get that. But the script I posted uses a completely different method of fullscreen which doesn't require user input, like all other desktop apps. Personally I'm never using the browser object to request fullscreen again for desktop games.

  • Hey,

    After speaking a bit with Dannyyy, I cleaned up the updated ForceRedraw addon I made.

    construct.net/construct-2/addons/435/greenworksredraw

    From my tests, this worked flawlessly. I can't really speak for performance but realistically there should be no issue.

    Just in case, I added actions to manually start and stop a constant redraw, and a param that gives you control over how many frames to skip before the next redraw occurs.

    If anyone gets issues using this, tag me here, or DM me on Discord via the CC discord server. I'll try to take a look and see what's wrong.

    EDIT: If anyone needs this to be ported to C3, also do tag me, or I'll just eventually port it one day when I have some time.

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