Jump to content

Brush tool in Phaser


Recommended Posts

Hi All,

I have been working on a Simple paint app for kids.

I have a problem in implementing the simple brush tool.  Im getting small dots and line here there in the screen

Unable to draw on free hand movement like a brush. kindly help.

playGame.prototype = {

  preload: function () {

  create: function () {
    game.stage.backgroundColor = '#222222';

    game.input.onDown.add(this.onStageDOwn, this);
    game.input.onUp.add(this.onStageUP, this);

  onStageUP: function () {
    game.input.deleteMoveCallback(this.paints, this);

  onStageDOwn: function (pointer, x, y) {
    graphicsMC = this.game.add.graphics();
    graphicsMC.lineStyle(2, 0xffd900, 1);
    graphicsMC.moveTo(pointer.x, pointer.y);
    game.input.addMoveCallback(this.paints, this);

  paints: function (pointer, x, y) {
    graphicsMC.lineTo(pointer.x, pointer.y);



Edited by samme
code format
Link to comment
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.
  • Create New...