Jump to content

Mask a rendertexture


Neogene
 Share

Recommended Posts

Hi folks,

 

i'm trying to create a sniper viewfinder using Phaser, my idea was to

 

1) draw scene

2) use a render texture to catpure a small area

3) mask the render texture using a  custom png shape.

 

//inside "preload"

       this.load.image('mask', 'assets/mask-test2.png');

//inside "create"

        var texture = game.add.renderTexture(300,300, 'content');               texture.resolution = 2;        texture.scaleMode = Phaser.scaleModes.linear;        game.add.sprite(300, 600, texture);        //Mask        var bmd = game.make.bitmapData(320, 256);        bmd.alphaMask('content', 'mask');<- type error here        game.add.image(300, 320, bmd).anchor.set(0.5, 0);
//inside "update":
 
  texture.renderXY(gameGroup, -150,-150, true);
There is an exception @ row 36556 in phaser latest version:    
  if (typeof sourceRect === 'undefined' || sourceRect === null)        {            this.draw(source).blendReset(); //Uncaught TypeError: cannot read property 'blendReset' of undefined        }

So there is no way to mask a renderTexture?

 

thank in advance.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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