Jump to content

Draw on BitmapData and add it to the stage


Recommended Posts

Hello, I need some help.

I want to draw something on BitmapData and add it to the stage. I've tryed this code (it's "create" function of my state):

this.backBMD = this.game.add.bitmapData(this.game.width, this.game.height);this.backBMD.strokeStyle('#fff');this.backBMD.beginPath(); this.backBMD.moveTo(0, 0);this.backBMD.lineTo(100, 100);this.backBMD.add(new Phaser.Sprite(this.game, 50, 50, 'ball_blue'));this.game.add.sprite(50, 50, this.backBMD);

I draw a line and add sprite to my bitmapData. Then I add it as a sprite and see nothing on my canvas.


However, this code is working fine:

this.game.add.sprite(50, 50, 'ball_blue');


Is it correct approach, or I've made some mistake?

Thanks, in advance.

Link to comment
Share on other sites


  • Recently Browsing   0 members

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