xinke
November 7, 2017, 2:13am
#1
openfl:6.3.0 ,lime: 5.8.0
编译条件为canvas时,采用shape作为mask是对的; 如下效果:
编译条件为webgl时,采用shape作为mask是错误的,不能对mask进行渲染。
测试代码如下:
package;
import openfl.display.Shape;
import openfl.display.Sprite;
class Main extends Sprite {
public function new () {
super ();
var mask:Shape = new Shape();
mask.graphics.beginFill(0x00ff00);
mask.graphics.drawRect(0,0,50,50);
mask.graphics.endFill();
mask.rotation = 60;
mask.x = 100;
mask.y = 100;
var test:Sprite = new Sprite();
test.graphics.beginFill(0xff0000);
test.graphics.drawRect(0,0,300,300);
test.graphics.endFill();
test.mask= mask;
this.addChild(test);
this.addChild(mask);
this.addEventListener(openfl.events.Event.ENTER_FRAME,function(e){
mask.rotation += 1;
trace('hello world');
});
}
}
xinke
November 9, 2017, 1:12am
#2
之前关于mask的问题:
I'm so sorry for my poor english ! I found some questions about mask when the mask is rotating and moving. For example: 1) no mask: All platforms are right !
class Main extends Sprite
{
public function new()
{
super();
var test:Sprite = new Sprite();
test.graphics.beginFill(0xff0000);
test.graphics.drawRect(0, 0, 200, 200);
test.graphics.endFill();
this.addChild(test);
var mas:Sprite = new Sprite();
mas.graphics.beginFill(0x0000ff);
mas.graphics.drawRect(0, 0, 10, 30);
mas.gr…
Right now, we only support non-rotated square masking on GL, but I hope we can improve this soon
Great news!
This is now implemented in our OpenGL renderer – your sample works
However, it’s using a stencil buffer, which means it is there no smoothing enabled. The edges of the rotating square are a bit jaggy, but we are clipping now.
I plan on getting cacheAsBitmap
+ mask
working enabling smoothing and finer support for transparency