Created
April 8, 2012 05:30
-
-
Save therealplato/2334957 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I have an index.html loading kinetic-v3.8.3.js, hexlib.js and perspective.js in that order | |
I am trying to segregate the mathematics of a hex grid in my hexlib.js file, while keeping the code to draw hexes in perspective.js | |
I am trying to access a function that is defined in hexlib.js from perspective.js but I have screwed it up. Here is the trace yielded by Firebug: | |
error in perspective.js (line 33) | |
Sexy is not defined | |
[Break On This Error] | |
Offending code: | |
ctx.grid = Sexy.Grid(10,10); //this returns Sexy.hexes | |
perspective.js looks like: | |
//perspective.js | |
(function() { | |
var ctx={}; | |
window.onload=function() { | |
ctx.grid=Sexy.Grid(10,10); | |
ctx.grid['0']['0'] | |
}; | |
})(); | |
hexlib.js contains Sexy and Sexy.Grid: | |
//hexlib.js | |
(function() { //beginning of enclosing function | |
var Sexy={}; //create Sexy namespace | |
Sexy.hexes={}; //this will hold Hex objects | |
Sexy.Grid = function(m,n,drawFunc) { | |
...put stuff in Sexy.hexes, Sexy.verts and more! | |
return Sexy.hexes; | |
} | |
If you want the full source: | |
https://github.com/therealplato/perspective/tree/combined | |
or | |
git clone git@github.com:therealplato/perspective.git | |
cd perspective | |
git checkout combined | |
node app.js | |
browse to http://localhost:3210/ in browser and open console to see error. This is probably not the last problem but if it is, you will see a hex grid in the browser that is passing data back and forth to node.js. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment