Only Google Chrome?

Get help using Construct 2

Post » Fri Nov 25, 2011 12:15 pm

How to make so that game it was started only in Google Chrome?
I did so:

But it doesn't work in Linux, as FPS <60 in Chrome.
Game Angry Birds example in Opera:
B
18
S
2
G
2
Posts: 21
Reputation: 2,413

Post » Fri Nov 25, 2011 1:24 pm

I would do it with a bit of javascript and css.

This is the javascript part, then you could make a not chrome div in the html and show it.

var userAgent = navigator.userAgent.toLowerCase();
$.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());

// Is this a version of Chrome?
if($.browser.chrome){
   //INITIALIZE CONSTRUCT
} else {
   $("#div-nochrome").show();
}0plus12011-11-25 13:25:44
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Fri Nov 25, 2011 2:15 pm

Thanks
B
18
S
2
G
2
Posts: 21
Reputation: 2,413

Post » Fri Nov 25, 2011 2:51 pm

It is impossible to me. It is possible to set an example?
B
18
S
2
G
2
Posts: 21
Reputation: 2,413

Post » Fri Nov 25, 2011 2:56 pm

This si the index.html that construct generates, open it and change everything to this:

<!DOCTYPE html>
<html manifest="offline.appcache">
<head>
    <meta charset="UTF-8" />
     
     <!-- This ensures the canvas works on IE9+. Don't remove it! -->
     <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=IE8" />
     
     <title>Test</title>
     <!-- Note: running this exported project from disk may not work exactly like preview, since browsers block some features on the file:// protocol. Once you've uploaded it to a server, it should work OK. -->
     
    <!-- This outlines the canvas with a black border. -->
     <style type="text/css">
          canvas { border: 1px solid black; }
     </style>

</head>

<body>
     <div id="fb-root"></div>
     <div style="text-align: center;" id="canvas-container">

        <!-- The canvas the project will render to. If you change its ID, don't forget to change the
        ID the runtime looks for in the jQuery ready event (above). -->
          <canvas id="c2canvas" width="640" height="480" oncontextmenu="return false;" onselectstart="return false;">
            <!-- This text is displayed if the visitor's browser does not support HTML5.
            You can change it, but it is a good idea to link to a description of a browser
            and provide some links to download some popular HTML5-compatible browsers. -->
               Your browser does not appear to support HTML5. Try upgrading your browser to the latest version. <a href="http://www.whatbrowser.org">What is a browser?</a>
               <br/><br/><a href="http://www.microsoft.com/windows/internet-explorer/default.aspx">Microsoft Internet Explorer</a><br/>
               <a href="http://www.mozilla.com/firefox/">Mozilla Firefox</a><br/>
               <a href="http://www.google.com/chrome/">Google Chrome</a><br/>
               <a href="http://www.apple.com/safari/download/">Apple Safari</a><br/>
               <a href="http://www.google.com/chromeframe">Google Chrome Frame for Internet Explorer</a><br/>
          </canvas>

    </div>
     
     <div id="no-chrome" style="display:none">
          YOUR BROWSER IS NOT CHROME
     </div>
     <!-- Pages load faster with scripts at the bottom -->
     
     <!-- Construct 2 exported games require jQuery. To save bandwidth, by default
     this is set to grab it off the Google content delivery network (CDN). Fall back to local if not available. -->
     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>
     <script>window.jQuery || document.write("<script src='jquery-1.6.3.min.js'>\x3C/script>")</script>


     
    <!-- The runtime script. You can rename it, but don't forget to rename the reference here as well.
    This file will have been minified and obfuscated if you enabled "Minify script" during export. -->
     <script src="c2runtime.js"></script>

    <script>
        // Start the Construct 2 project running on window load.
        jQuery(document).ready(function ()
        {
               var userAgent = navigator.userAgent.toLowerCase();
               $.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());
            if($.browser.chrome){
                    // Create new runtime using the c2canvas
                    cr.createRuntime("c2canvas");
                  //INITIALIZE CONSTRUCT
               } else {
                  $("#no-chrome").show();
                  $("#canvas-container").hide();
               }
        });
    </script>
</body>
</html> 0plus12011-11-25 15:00:42
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Fri Nov 25, 2011 3:05 pm

Yes it works. Thanks.

And where to add the reference to a picture about the prevention?
B
18
S
2
G
2
Posts: 21
Reputation: 2,413

Post » Fri Nov 25, 2011 3:21 pm

Put your html here:

<div id="no-chrome" style="display:none">
          YOUR BROWSER IS NOT CHROME
     </div>
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Post » Fri Nov 25, 2011 3:27 pm

I am grateful to you for the help. Thanks.
B
18
S
2
G
2
Posts: 21
Reputation: 2,413

Post » Fri Nov 25, 2011 4:37 pm

The HTML content shown between the <canvas> and </canvas> tags in the exported page is shown if the browser doesn't support canvas. You should just use that, it's much easier!
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,468

Post » Fri Nov 25, 2011 4:53 pm

why only chrome? I use only Opera & Firefox...
B
4
S
1
G
1
Posts: 36
Reputation: 949

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 16 guests