proyb2 Posted June 23, 2015 Share Posted June 23, 2015 Tried to create new polygon without success if using x, y as a variables in place of numbers. How do I use variables? var g = game.add.graphics(0,0); var poly = new Phaser.Polygon(); var aa = new Array; aa.push(new Phaser.Point(x,y)) aa.push(new Phaser.Point(x,y1)) aa.push(new Phaser.Point(x1,y1)) aa.push(new Phaser.Point(x,y1)) poly.setTo(aa); g.beginFill(0xFF33ff); g.drawPolygon(poly.points); g.endFill(); Link to comment Share on other sites More sharing options...
drhayes Posted June 24, 2015 Share Posted June 24, 2015 What does "without success" mean? Were you seeing errors in the JavaScript console? What were they? What are the values of x, y, x1, and y1? Link to comment Share on other sites More sharing options...
proyb2 Posted June 24, 2015 Author Share Posted June 24, 2015 What does "without success" mean? Were you seeing errors in the JavaScript console? What were they? What are the values of x, y, x1, and y1? x, y, x1, y1 are numbers e.g. x=100 It wasn't visible on the world unless I have replaced it with the 4 variables with numbers. There is no error. Link to comment Share on other sites More sharing options...
proyb2 Posted June 24, 2015 Author Share Posted June 24, 2015 http://phaser.io/examples/v2/geometry/polygon#gv Lines 40:poly.setTo([ new Phaser.Point(200, 100), new Phaser.Point(350, 100), new Phaser.Point(375, 200), new Phaser.Point(150, 200) ]); with using new Phaser.Point(x,y) Link to comment Share on other sites More sharing options...
Skeptron Posted June 24, 2015 Share Posted June 24, 2015 Don't know if this is causing the bug but you're giving twice the same set of coords : aa.push(new Phaser.Point(x,y))aa.push(new Phaser.Point(x,y1)) // Hereaa.push(new Phaser.Point(x1,y1))aa.push(new Phaser.Point(x,y1)) // And thereShouldn't it be : aa.push(new Phaser.Point(x,y))aa.push(new Phaser.Point(x,y1))aa.push(new Phaser.Point(x1,y1))aa.push(new Phaser.Point(x1,y)) // <- Changeinstead? Link to comment Share on other sites More sharing options...
Recommended Posts