iceherosubzero Posted July 15, 2015 Share Posted July 15, 2015 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. Thanks,Iceheros Quote Link to comment Share on other sites More sharing options...
ChM Posted July 16, 2015 Share Posted July 16, 2015 window is a global object, you should be able to access it in any script. Do you actually get an error message? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.