openfl / starling

Known as the "Cross-Platform Game Engine", Starling is a popular Stage3D framework for OpenFL and Haxe
Other
236 stars 68 forks source link

Haxe port of Starling extension TextureMask #49

Closed jrock24 closed 7 years ago

peteshand commented 7 years ago

out of curiosity, is there an example of how this is used somewhere?

jrock24 commented 7 years ago

Example usage:

_field = new Image(new Texture("field_texture"));
_field.alignPivot();
_gameLayer.addChild(_field);

fieldMask = new TextureMask("field_texture");
fieldMask.alignPivot();
fieldMask.touchable = false;
fieldMask.visible = false;
fieldMask.threshold = .3;
_gameLayer.addChildAt(fieldMask, 0);

card.shadow.mask = _view.fieldMask

This creates a mask the shape of the field texture in order to keep the card shadow only on the field.

TerryCavanagh commented 7 years ago

Nice! A friend of mine was literally asking me about this missing feature yesterday.

Here's an example with info about the extension: http://wiki.starling-framework.org/extensions/texture_mask