ABev Posted January 7, 2014 Share Posted January 7, 2014 I'd like to draw some circles and lines that need to be dynamically shaped and sized (so just using textures isn't an option) I've run across both Phaser.Graphics and the Phaser.BitmapData objects which seem to have a similar purpose. Can someone explain the difference intentions for their use? And is it possible to use BitmapData with WebGL rendering (the interface seems quite like the 2d canvas)? Thanks! Link to comment Share on other sites More sharing options...
rich Posted January 7, 2014 Share Posted January 7, 2014 Phaser.Graphics creates the primitives using vectors in WebGL. It's fine if you only need a handful of them, but slows down really quickly if you start ramping up the numbers. BitmapData works by creating a texture and uploading it to WebGL each time you modify it, but at least it's just a single transfer. Even so, if you can avoid doing it (by using Graphics) then I would start off by trying there first. Link to comment Share on other sites More sharing options...
Mike Posted January 7, 2014 Share Posted January 7, 2014 On the topic I found a way to draw a rectangle but i didn't find a polygon method and i went for this: drawPoly :function(poly){ var graphics = this.add.graphics(0, 0); graphics.beginFill(0xFF3300); graphics.lineStyle(10, 0xffd900, 1); graphics.moveTo(poly[poly.length-1].x,poly[poly.length-1].y); for(var i=0,len = poly.length-1; i<=len; i++){ graphics.lineTo(poly[i].x, poly[i].y); } graphics.endFill(); graphics.alpha = 0.4; } Should I try adding this to Phaser core and make a PR ? Or is there other plans or ways for this... Link to comment Share on other sites More sharing options...
rich Posted January 7, 2014 Share Posted January 7, 2014 Check it's not in Pixi 1.4 first (as we'll update to that v. v. soon) but if not then sure, submit a PR (against the dev branch only) Link to comment Share on other sites More sharing options...
Recommended Posts