driiper Posted February 4, 2015 Share Posted February 4, 2015 Hello! I'm trying to draw a simple polygon in phaser, but for some reason i get: My whole code is: (Coffee) game = new Phaser.Game config.width, config.height, Phaser.AUTO graphics = game.add.graphics(0, 0); # FAIL ON THIS $.getJSON "assets/json/json.json", (data)-> $.each data, (key, polygon) -> p = new Phaser.Polygon(polygon); graphics.beginFill(0xFF33ff); graphics.drawPolygon(p.points); graphics.endFill(); I get the following error;Uncaught TypeError: Cannot read property 'graphics' of nullMost places ive seen im doing this correct. It may be some coffescript silly bug? (Compiled JS) var game, graphics; game = new Phaser.Game(config.width, config.height, Phaser.AUTO); graphics = game.add.graphics(0, 0); $.getJSON("assets/json/json.json", function(data) { return $.each(data, function(key, polygon) { var p; p = new Phaser.Polygon(polygon); graphics.beginFill(0xFF33ff); graphics.drawPolygon(p.points); return graphics.endFill(); }); });Anyone have any idea? ThanksDriiper Link to comment Share on other sites More sharing options...
Recommended Posts