Jump to content

pacman shape (drawn with arc)

jorge nunez

Recommended Posts

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.arc(0, 0, 200, game.math.degToRad(360-90-45/2), game.math.degToRad(360-90+45/2), false);
    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.pivot.x = game.width/2;
    sprite1.pivot.y = game.height/2;
    sprite1.angle += 0*45;

Link to comment
Share on other sites

In v3 you need to do it like this:

graphics.fillStyle(0xffff00, 1);

graphics.moveTo(400, 300);
graphics.arc(400, 300, 200, Phaser.Math.DegToRad(0), Phaser.Math.DegToRad(45), true, true);


Where 400x300 is the center of the arc and 200 is the radius.

Link to comment
Share on other sites

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


  • Recently Browsing   0 members

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