我正在尝试绘制一个用圆圈遮罩的对象,但应用的蒙版更像是一个圆圈的边界矩形
我尝试使用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;”检查了掩码的样子。线
答案 0 :(得分:2)
这应该在当前的OpenFL版本中解决:
https://github.com/openfl/openfl/blob/develop/CHANGELOG.md#650-11102017
您还可以使用Cairo(在本机平台上)或Canvas(在HTML5上)获得更流畅/更好的屏蔽支持:
openfl test html5 -Dcanvas
openfl test windows -Dcairo
当您bitmapData.draw
,sprite.cacheAsBitmap = true
或其他触发软件渲染而不是GL的API时,也会使用这些。