我想要一个精灵与生成的纹理从hexGraphics(Phaser.Graphics),这是由hexMask对象遮罩
var hexGraphics = new Phaser.Graphics()
.beginFill(0x898989)
.drawRect(0,0,80,80);
var hexMask = new Phaser.Graphics()
.beginFill(0x0)
.drawCircle(0,0,50)
;
game.add.sprite(10,10,hexGraphics.generateTexture()); //working
game.add.sprite(110,10,hexMask.generateTexture()); //working
hexGraphics.mask = hexMask; // http://www.goodboydigital.com/pixijs/docs/classes/Graphics.html mask property
game.add.sprite(110,110,hexGraphics.generateTexture()); // no wai =(这是小提琴http://jsfiddle.net/vnbvL50h/1/
有任何想法如何生成蒙版纹理或修复此示例?
发布于 2015-01-19 22:45:57
我已经编辑了小提琴,遮罩现在可以工作了,我不确定这是否是你想要的结果,但基本上你不能使用一个图形对象来遮罩另一个图形对象,你必须使用Sprite。
// create a sprite, keep a reference of it and mask it
var hexSprite = game.add.sprite(0,0,hexGraphics.generateTexture());
hexSprite.mask = hexMask;以下是关于掩码的官方pixi示例:http://www.goodboydigital.com/pixijs/examples/14/
https://stackoverflow.com/questions/27853629
复制相似问题