Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.4.4] cacheAsBitmap breaks graphics as mask #2152

Closed
jmp909 opened this issue Oct 22, 2015 · 3 comments
Closed

[2.4.4] cacheAsBitmap breaks graphics as mask #2152

jmp909 opened this issue Oct 22, 2015 · 3 comments

Comments

@jmp909
Copy link

jmp909 commented Oct 22, 2015

using a cached graphic as a mask used to work but not as of 2.4.4

var gMask = game.add.graphics(0, 0);
gMask.lineStyle(2, 0xFF0000, 1);
gMask.beginFill(0xFF0000,0.1)
gMask.drawCircle(0,0,mapSize/2,mapSize/2);    
gMask.endFill()

gMask.cacheAsBitmap=true // !!!! breaks mask

renderGroup.add(gMask)
renderSprite.mask=gMask;

error
Uncaught TypeError: Cannot read property 'data' of undefined
(phaser.js 17578)

seems to be this line
if(!maskData._webGL[gl.id].data.length)return;

@geros
Copy link

geros commented Dec 30, 2015

Have you found any workaround on this?
It happens to me when i use renderer:Phaser.WEBGL while works fine when i change it to Phaser.CANVAS

@jmp909
Copy link
Author

jmp909 commented Jan 6, 2016

quick fix for WebGL Graphics is to manually set the mask as dirty

..
gMask.cacheAsBitmap=true;
gMask.dirty=true // call this before applying the mask
..
this.renderSprite.mask=gMask;

but ideally would presumably for this to happen in the PIXI source in this function
Object.defineProperty(PIXI.DisplayObject.prototype, 'mask', {

https://github.com/photonstorm/phaser/blob/c9c85330ab60547b39ba4c9400c258ed7fb2a317/src/pixi/display/DisplayObject.js#L302

note: it'll get set to dirty=false automatically on the next update, so it's not being continually marked as dirty

@photonstorm
Copy link
Collaborator

Thank you for taking the time to open this issue. However, official support for Phaser 2 has now ended as we focus on preparing Phaser 3 for beta release. In a bid to keep the project tidy, and avoid confusion, we are closing all v2 related issues.

This does not mean your issue won't be looked-at. In November 2016 the Phaser CE (Community Edition) project began. The aim of Phaser CE was to allow the community to continue v2 development. Since then it has gained significant traction, with many updates and releases.

If you are still interested in having your issue investigated we strongly recommend testing the latest Phaser CE release. And only if the problem persists, opening an issue on the Phaser CE repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants