Jump to content

Iframe redirect to game freezes game onclick


Bertram
 Share

Recommended Posts

Hello,

 

I have a IFrame and within the iframe I redirect to the game.html. When I click in the game.html everything freezes.

 

 

Everything works fine when using a computer (any browser), windows phone or android, but with an iphone or ipad it won't work.

 

Below are the example files to replay the problem...

 

index.html:

<html><body>	<iframe src="click.html" height="900" width="800"/></body></html>

click.html

<!DOCTYPE html><html>        <body>      <a href="Game.html">CLICK HERE</a>    </body></html>

Game.html

<!DOCTYPE html><html>    <head>           <style>            body{overflow:hidden;}             #game_div {                 width: 760px;                 height: 1100px;                 margin: auto;             }        </style>        <script type="text/javascript" src="./Game/phaser.min.js"></script>        <script type="text/javascript" src="./Game/main.js"></script>    </head>    <body>      <div id="game_div"> </div>    </body></html>

main.js

var game = new Phaser.Game(760, 1100, Phaser.AUTO, 'game_div');var overlay, countdownText;var counter = 0;var main_state = {    preload: function() {		           },    create: function () {               //game overlay		overlay = game.add.graphics(0, 0);		overlay.beginFill(0x00A54F, 0.8);		overlay.drawRect(0, 0, game.width, game.height);		countdownText = game.add.text((game.width / 2), (game.height / 2), counter, { font: "65px Arial", fill: "#ffffff", align: "center" });        countdownText.anchor.set(0.5,0.5);		    },    update: function() {        countdownText.setText(counter++);    }}game.state.add('main', main_state);  game.state.start('main');  

TNX

Link to comment
Share on other sites

When I redirect the link in the iFrame to a page containing canvas code without Phaser it has no problem (used this code http://www.html5canvastutorials.com/advanced/html5-canvas-linear-motion-animation/) and when I redirect it to an example page of Phaser (http://examples.phaser.io/_site/view_full.html?d=animation&f=group+creation.js&t=group%20creation) it also freezes.

 

UPDATE: With Sanatan I tried some other possibilities:

- Change Phaser.AUto to Phaser. Canvas

- try a pixi.js game (http://aheadware.com/html5games-portfolio/games/yummyplate/) *This does work

- try a panda.js game (http://www.bram.us/2014/02/15/panda-js-html5-game-engine/) *this also works

 

no solution found

Link to comment
Share on other sites

Your above code (in the first post) works perfectly for me on iOS 6 and 7. No lock-up, no freezing, counter runs as expected.

 

Whatever is causing the iOS freeze isn't found in the code above, or in Phaser specifically I doubt, but somewhere else in your game. I was using a 2.0.5 build but I still don't think it will make any difference, I'll swap it for an older one later to double-check, but I'd put good money on the error being game iOS specific. Probably something non obvious like an audio file encoding bitrate or something.

Link to comment
Share on other sites

I will try with an 2.0.5 build, because I get the error with only the code above nothing more than that.

 

To be clear step by step:

- I open index.html on an iPad or iPhone (xCode simulator has the same result)

- I click the link 'click here'

- I see a number being updated every update();

- when I click anywhere in the game canvas (the green rectangle), the counter stops. freezes

 

UPDATE:
I have set all the code at http://bertramvandeven.nl/phasertest/ with phaser 2.0.5 and tried it again with an iphone 7.1.1 but still the same result...

Link to comment
Share on other sites

- when I click anywhere in the game canvas (the green rectangle), the counter stops. freezes

 

Now that's a whole different sort of issue :)

 

I'll need to get back to my PC to check, but I assume the iframe jump is confusing the game focus. Throw this into your create:

game.stage.disableVisibilityChange = true;

And re-test. My guess would be it no longer freezes.

Link to comment
Share on other sites

That works! 

 

Sorry for not being clear enough... I think my "I click in the game.html" was not clear.

 

 

I have a IFrame and within the iframe I redirect to the game.html. When I click in the game.html everything freezes

 

But it keeps a bit strange that this only happens within ios in combination with the iphone or ipad.

 

Thanks again for the solution....

Link to comment
Share on other sites

  • 9 months later...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...