Skip to content

Extension for the Sparrow Framework, providing pixel level masking for any Sparrow display object.

Notifications You must be signed in to change notification settings

Gamua/Sparrow-Extension-Masked-Sprite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Sparrow Extension: Masked Sprite

The Sparrow Extension class "SXMaskedSprite" provides pixel level masking for any Sparrow display object.

Use the class as a replacement for a normal Sprite. It contains a public property called "mask" that can be set to any display object. As each frame progresses, custom blend filters will apply the mask's alpha channel to the contents of the sprite. Both animated and static display objects are supported.

Installation

Add the class files from the src-directory to your Sparrow-powered game.

Demo-Project

The demo-directory contains a sample project. If you have configured your system for Sparrow, the project should compile and run out of the box.

Sample Code

Create the sprite class and attach any display object to it, and it will act as a mask. There is no need to add the mask to the display list; you can change its position, scale, alpha, etc. to achieve different effects.

// create masked sprite and add some children
SXMaskedSprite *sprite = [SXMaskedSprite sprite];
[sprite addChild:...];

// create a mask
SPImage *mask = [SPImage imageWithContentsOfFile:@"my_mask.png"];

// apply the mask to the sprite
sprite.mask = mask;

More information

Additional information can be found in the Sparrow wiki. Thanks a lot to Jonathan Hart — his Pixelmask Starling extension was the inspiration for this port.

About

Extension for the Sparrow Framework, providing pixel level masking for any Sparrow display object.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published