Jump to content

How to access window.parent from within phaser?


Recommended Posts

Hello all,


I have made a game in 2D. It is a simple drag and drop game.

I want to access the window element of the browser in my game so that a function residing in my html page gets called from my game code.


The game is loaded in an iframe of another html page  say 1.html where my othercode() function resides and I want to access this othercode() function from my theGame.js file.


here is the structure of my html page.

<!doctype html><html>    <head>        <meta charset="UTF-8" />        <title>-ABC-</title>        <script type="text/javascript" src="js/phaser.min.js"></script>        <!--script type="text/javascript" src="js/phaser.js"></script>        <script type="text/javascript" src="js/phaser.map"></script-->        <script src="src/boot.js"></script>        <script src="src/preload.js"></script>        <script src="src/gametitle.js"></script>        <script src="src/thegame.js"></script>        <script src="src/infoscreen.js"></script>        <script src="src/winscreen.js"></script>        <script src="src/gameover.js"></script>        <link rel="stylesheet" href="assets/fonts/stylesheet.css" type="text/css" charset="utf-8" />    <style type="text/css">                    body{                        margin: 0;                font-family: 'vag_roundedbold';                            }        </style>        <script>        var stageWidth=990;        var stageHeight=485;                (function() {                var game = new Phaser.Game(stageWidth, stageHeight, Phaser.CANVAS, "game");                game.state.add("Boot",boot);                game.state.add("Preload",preload);                game.state.add("GameTitle",gameTitle);                game.state.add("InfoScreen",infoScreen);                game.state.add("TheGame",theGame);                game.state.add("WinScreen", winScreen);                game.state.add("GameOver",gameOver);                game.state.start("Boot", true, false, "game");            })();            </script>    </head>    <body>  </body></html>

and I am loading various JS files for various screens such as "titlescreen", "gamescreen", "winscreen" etc...


I want to access the browsers "window.parent" in my "theGame.js" file.


How can I pass a reference of the "window.parent" to my file "theGame.js".


Your help will be highly appreciated.




Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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