Jump to content

Brush tool in Phaser


GideonSam
 Share

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

 Share

  • Recently Browsing   0 members

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