jorge nunez Posted April 1, 2018 Share Posted April 1, 2018 i'm trying to draw pacman shapes, or slices of pie, they are basically the same what i want is something like this: i know it's an example i can copy and paste from the webpage but it only works on phaser 2, i'm using phaser 3 rather than getting a pie shape i get this: as you can see, it fills the arc with a straight line, but what i want is to complete the shape taking the center of the circle into account, here is the code: style = { font: "bold 14px Arial", fill: "#FFF", boundsAlignH: "center", boundsAlignV: "middle", wordWrap: true, wordWrapWidth: 80 }; graphics1 = game.add.graphics(game.width/2, game.height/2); graphics1.beginFill(0x0000FF); graphics1.arc(0, 0, 200, game.math.degToRad(360-90-45/2), game.math.degToRad(360-90+45/2), false); graphics1.endFill(); text1 = game.add.text(game.width/2-40, game.height/4-40, "phaser 2.4 text bounds", style); text1.align = 'center'; //text1.setTextBounds(game.width/3, 0, game.width/3, game.height/2); sprite1 = game.add.sprite(game.width/2,game.height/2); sprite1.addChild(graphics1); sprite1.addChild(text1); sprite1.pivot.x = game.width/2; sprite1.pivot.y = game.height/2; sprite1.angle += 0*45; Link to comment Share on other sites More sharing options...
rich Posted April 4, 2018 Share Posted April 4, 2018 In v3 you need to do it like this: graphics.fillStyle(0xffff00, 1); graphics.beginPath(); graphics.moveTo(400, 300); graphics.arc(400, 300, 200, Phaser.Math.DegToRad(0), Phaser.Math.DegToRad(45), true, true); graphics.closePath(); graphics.fillPath(); Where 400x300 is the center of the arc and 200 is the radius. cristlee 1 Link to comment Share on other sites More sharing options...
jorge nunez Posted April 4, 2018 Author Share Posted April 4, 2018 many thanks, i was struggling with the documentation, when i started noticing that all the documentation was for phaser 2 it was too late, i normally prefer to go with lts (long term support) than being an early adopter, i though to myself "forget about looking for a book for that version" Link to comment Share on other sites More sharing options...
Recommended Posts