RubyHelix Posted July 21, 2014 Share Posted July 21, 2014 I've been using this forum as a valuable tool along with all the wonderful examples provided to us. I finally have my first simple HTML5 game nearly complete but i'm having an issue with accessing the global variables in the Full Screen Mobile Template. I'll post the code I'm talking about below: Boot.jsBasicGame = { // GLOBAL VARIABLES score: 0, // MUSIC THAT PLAYS BETWEEN STATES music: null, // CHECK AGAINST DEVICE ORIENTATION TO DETERMINE BEHAVIOR OF GAME orientated: false };BasicGame.Boot = function (game) {};BasicGame.Boot.prototype = { preload: function () { },Now, first I had noticed that in this template variables don't look like how I would normally declare a variable:var score = 0;In my loop timer I basically have the timer increment the score: Game.jsupdateCounter: function() { score++; scoreText.setText("Score: " + score); }If I use the above code without first declaring the score variable in this state then I get a variable undeclared error. My concept is that I want to add the score to the MainMenu state but when attempting to do so it states the variable is not declared. How would I access the global variable from another game state when declaring it as has been done in this template? Thanks for any help you can provide! Link to comment Share on other sites More sharing options...
Dumtard Posted July 21, 2014 Share Posted July 21, 2014 BasicGame.score Dread Knight 1 Link to comment Share on other sites More sharing options...
RubyHelix Posted July 21, 2014 Author Share Posted July 21, 2014 Works perfectly thank you. Link to comment Share on other sites More sharing options...
Recommended Posts