Jump to content

Drawing a polygon (Wtf?)


driiper
 Share

Recommended Posts

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 null

Most 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? :)

 

 

Thanks

Driiper

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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