圆形遮罩就像矩形一样
Circle mask acts like rectangle
我正在尝试绘制一个用圆圈遮盖的对象,但应用的遮罩更像是圆圈的边界矩形
我尝试使用通过 drawCircle 方法绘制的圆:
private function squareToRound(ability:MovieClip):MovieClip
{
var container:MovieClip = new MovieClip();
var newAbility:MovieClip = ability;
var newMask:MovieClip = new MovieClip();
newAbility.width = 43;
newAbility.height = 43;
newMask.x = newAbility.x + newAbility.width / 2;
newMask.y = newAbility.y + newAbility.height / 2;
container.addChild(newAbility);
newMask.graphics.beginFill();
newMask.graphics.drawCircle(0, 0, 8);
newMask.graphics.endFill();
container.addChild(newMask);
newAbility.mask = newMask;
return container;
}
... 并且作为来自 SWF 的资产:
private function squareToRound(ability:MovieClip):MovieClip
{
var container:MovieClip = new MovieClip();
var newAbility:MovieClip = ability;
var newMask:MovieClip = new CircleAbilityMask();
newAbility.width = 43;
newAbility.height = 43;
newMask.x = newAbility.x + newAbility.width / 2;
newMask.y = newAbility.y + newAbility.height / 2;
container.addChild(newAbility);
container.addChild(newMask);
newAbility.mask = newMask;
return container;
}
结果相等。
我通过评论 "newAbility.mask = newMask;" 行
检查了面具的样子
这应该在当前的 OpenFL 版本中得到解决:
https://github.com/openfl/openfl/blob/develop/CHANGELOG.md#650-11102017
您还可以使用 Cairo(在本机平台上)或 Canvas(在 HTML5 上)以获得 smoother/better 掩码支持:
openfl test html5 -Dcanvas
openfl test windows -Dcairo
当您 bitmapData.draw
、sprite.cacheAsBitmap = true
或其他触发软件渲染而不是 GL 的 API 时,也会使用这些。
我正在尝试绘制一个用圆圈遮盖的对象,但应用的遮罩更像是圆圈的边界矩形
我尝试使用通过 drawCircle 方法绘制的圆:
private function squareToRound(ability:MovieClip):MovieClip
{
var container:MovieClip = new MovieClip();
var newAbility:MovieClip = ability;
var newMask:MovieClip = new MovieClip();
newAbility.width = 43;
newAbility.height = 43;
newMask.x = newAbility.x + newAbility.width / 2;
newMask.y = newAbility.y + newAbility.height / 2;
container.addChild(newAbility);
newMask.graphics.beginFill();
newMask.graphics.drawCircle(0, 0, 8);
newMask.graphics.endFill();
container.addChild(newMask);
newAbility.mask = newMask;
return container;
}
... 并且作为来自 SWF 的资产:
private function squareToRound(ability:MovieClip):MovieClip
{
var container:MovieClip = new MovieClip();
var newAbility:MovieClip = ability;
var newMask:MovieClip = new CircleAbilityMask();
newAbility.width = 43;
newAbility.height = 43;
newMask.x = newAbility.x + newAbility.width / 2;
newMask.y = newAbility.y + newAbility.height / 2;
container.addChild(newAbility);
container.addChild(newMask);
newAbility.mask = newMask;
return container;
}
结果相等。
我通过评论 "newAbility.mask = newMask;" 行
检查了面具的样子这应该在当前的 OpenFL 版本中得到解决:
https://github.com/openfl/openfl/blob/develop/CHANGELOG.md#650-11102017
您还可以使用 Cairo(在本机平台上)或 Canvas(在 HTML5 上)以获得 smoother/better 掩码支持:
openfl test html5 -Dcanvas
openfl test windows -Dcairo
当您 bitmapData.draw
、sprite.cacheAsBitmap = true
或其他触发软件渲染而不是 GL 的 API 时,也会使用这些。