Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A syncWith method for Pixelmask. #77

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

A syncWith method for Pixelmask. #77

wants to merge 5 commits into from

Conversation

haydn
Copy link

@haydn haydn commented Apr 11, 2012

I've added a method to Pixelmask that makes it easy to sync it with an instance of Image. For example in an entity you might have this:

public function MyEntity()
{
    var image:Image = new Image(IMAGE);

    image.originX = -200;
    image.angle = 45;

    graphic = image;
    mask = new Pixelmask(image);
}

That will automatically create a pixel mask with the same bounds and matching data to the image.

If the image is constantly updating the Pixelmask can be updated with it. Just use the syncWith method:

override public function update():void
{
    super.update();

    (graphic as Image).angle += 5;
    (mask as Pixelmask).syncWith(graphic as Image);
}

@jisbruzzi
Copy link

Why not just use Image objects for collisions instead of masks? I mean, youcan do a lot of transformations much easily.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants