jorge nunez

pacman shape (drawn with arc)

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.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;

Share this post

Link to post
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.

Share this post

Link to post
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"

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.