So I decided today to play around with LimeJS a bit, I've never used Closure before so that is new to me as well. I've run into a small problem right off the bat and am not sure what is wrong.
So far my project is only three files: firstGame.html
, firstGame.js
, `player.js
firstGame.html:
<!DOCTYPE HTML>
<html>
<head>
<title>firstGame</title>
<script type="text/javascript" src="../closure/closure/goog/base.js"></script>
<script type="text/javascript" src="firstGame.js"></script>
<script type="text/javascript" src="player.js"></script>
</head>
<body onload="firstGame.start()"></body>
</html>
firstGame.js:
goog.provide('firstGame');
//get requirements
goog.require('lime.Director');
goog.require('lime.Scene');
goog.require('lime.Layer');
goog.require('lime.Circle');
goog.require('lime.Label');
goog.require("lime.Sprite");
goog.require('lime.animation.Spawn');
goog.require('lime.animation.FadeTo');
goog.require('lime.animation.ScaleTo');
goog.require('lime.animation.MoveTo');
goog.require("firstGame.Player");
// entrypoint
firstGame.start = function(){
var director = new lime.Director(document.body,1024,768);
director.makeMobileWebAppCapable();
scene = new lime.Scene();
var background = new lime.Sprite().setSize(1524,768).setPosition(0,0).setFill(0,0,0).setAnchorPoint(0,0);
var player = new firstGame.Player();
scene.appendChild(background);
// set current scene active
director.replaceScene(scene);
}
//this is required for outside access after code is compiled in ADVANCED_COMPILATIONS mode
goog.exportSymbol('firstGame.start', firstGame.start);
and finally player.js(the idea was a custom ui component so I inherit from Sprite):
goog.provide("firstGame.Player');
goog.require('lime.Sprite');
// new constructor
firstGame.Player = function(){
// call parents constructor
goog.base(this);
// custom initialization code
this.color_ = 'red';
}
// define parent class
goog.inherits(firstGame.Player,lime.Sprite);
I then ran lime.py update
(not sure if I needed to because I was only adding a class and not a whole new namespace but figured I should just to be safe)
When I load the page I get the unexpected token error noted above, this happens on line 1 of player.js, goog.provide(). Now if I remove player.js from the script path in my html file I find my other code runs ok which suggests that I am linking to the Closure library as expected. It's just when I try to use it in player.js that I run into the problem. My first inclination was that maybe the code was executing before the Closure library was parsed, I looked for some hook to tie into when Closure loaded but couldn't find anything. I've Googled around and haven't found an answer. I feel like I am missing something simple but can't quite get it. If anyone had any advice I would appreciate it, thanks much!
goog.provide("firstGame.Player');
should be
goog.provide('firstGame.Player');
your qoutes don't match.