Jump to content

global object with game ?


bexphones
 Share

Recommended Posts

hi,

i have this index.html :

<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<title>my_game</title>
<style>
body {
	margin: auto;
	display: table;
	position: absolute;
	border:0px;
	top: 0px;
	left: 0px;
	padding: 0; margin: 0;
	background: #1f1d24
}
</style>
<script src="phaser.js"></script>
<script src="main.js"></script>
</head>
<body>
</body>
<script>

 game = new Phaser.Game( safe_zone_width + extra_width, safe_zone_height + extra_height, Phaser.CANVAS, 'game');


 game.state.add('boot', boot);
 game.state.add('preloader', preloader);
 game.state.add('the_game', the_game);
 game.state.start('boot');
})();
</script>

</html>

and i want to create a global object in my js.file.

i type this but that don't work. what's the true syntax ?

game.example=game.add.audio('clic')

and when i write console.log(game) in my main.js it say game is not defined ...why ?

sorry for this basic question but i want to understand

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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