Exporting HTML5 vs Cordova

Discussion and feedback on Construct 2

Post » Wed Mar 16, 2016 5:51 pm

I'm working on a cordova app that's going to house multiple games, some made with Construct, others from scratch. So far, I've built the cordova app from scratch and I've just been exporting my Construct games as HTML5 (in embed mode). They seem to be working fine within the cordova shell I've built.

Is there any advantage to exporting as cordova if I'm not going to be using the config.xml Construct generates?

Or to put it another way, does Construct export cordova differently than HTML5 other than just the inclusion of config.xml?

Thanks!
B
3
Posts: 4
Reputation: 179

Post » Sat Mar 19, 2016 3:33 pm

Okay, so in case anyone ever happens to have this same odd question, here's what I learned. There do appear to be some differences inside c2runtime.js that check for cordova specifically. Most of them seem relatively minor.

But the biggest difference is that within index.html, there are a couple listeners that will suspend the game when the app moves to the background. That turns out to be essential because if you don't suspend the game when the user switches apps, iOS will most likely kill and reboot the app, losing the user's progress.

So if you ever end up in a situation where you're building a cordova app where you load in a construct game (rather than just exporting a single construct game as a cordova app), make sure you listen for cordova's pause and play events, then call cr_setSuspended accordingly.

Aaaaand this will probably help no one. But I was pleased with myself that I figured it out.
B
3
Posts: 4
Reputation: 179

Post » Sat Mar 19, 2016 7:57 pm

Someone might find this useful in the future. Thanks for sharing.
B
129
S
33
G
17
Posts: 1,552
Reputation: 20,515

Post » Sat Mar 19, 2016 9:40 pm

dogjune wrote:Aaaaand this will probably help no one. But I was pleased with myself that I figured it out.


:D

You're the man! Thanks for sharing ;)
ImageImage
B
27
S
16
G
69
Posts: 948
Reputation: 39,105

Post » Sat May 28, 2016 12:27 pm

@dogjune
Interesting. Thank you for sharing. Does this mean that if I create an app via C2 and export it as HTML5, it won't have those listeners unless I export them as CORDOVA?

I find that when I export my project as CORDOVA the scaling is off when launching it using Cocoon, but not when it is exported as HTML5. Am I missing something?

EDIT: Nvm. I think the scaling was due to WebGL turned off. Enabling it seems to do the trick.
B
15
S
7
G
34
Posts: 55
Reputation: 18,478


Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 2 guests