Phaser.Graphics / PIXI.Graphics面具

时间:2015-01-09 04:03:59

标签: phaser-framework pixi.js

我想要一个带有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/

如何生成蒙版纹理或修复此示例的任何想法?

1 个答案:

答案 0 :(得分:1)

我已经编辑了小提琴并且屏蔽现在有效,我不确定这是否是您正在寻找的结果,但实质上您无法使用图形对象来屏蔽其他图形对象,你必须使用一个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/