Jump to content
Search Community

BlitMask + rotation

gigbig test
Moderator Tag

Recommended Posts

Hi, I am trying to create a smooth scroll effect: I have a wall that moves horizontally, and I am using 3 pieces with the old-school method. While shifting the wall rotates from x to y degrees. The result is ok, but I want to maximize performances: can I use BlitMask to create a shifting+rotating wall?

Is it correct to create the BlitMask for an item, add the item to a DisplayObject, and rotate the DisplayObject?

It seems to work ok, even if there is a minor glitch on the top side of the wall, showing the lowest pixels of the wall BMP and certain angles of the rotation (fixable with wrapOffsetY I suppose).

 

Thanks

Link to comment
Share on other sites

I don't think I'm visualizing the shifting rotating wall properly.

It doesn't sound like its something that we had in mind when BlitMask was created. The point being if you are constantly rotating the target of the BlitMask or children of the target, the BlitMask will constantly have to recapture the pixels of the target and run and update() which won't be terribly efficient. 

 

 

 

Again, I'm not quite following exactly what you want to accomplish.

I'm not sure if you should be rotating the content of the BlitMask (probably not) or a child of the BlitMask for the effect you want. 

 

I would suggest starting with a very basic BlitMask implementation and see how far you can take it. 

 

Perhaps once you have something in place we can take a peek and better assess the situation.

Link to comment
Share on other sites

Well, the solution I adopted seems to work great:

- I instantiated a piece of the wall to scroll

- I instantiated a blitmask with the wall as target, and enabled the wrap and autoupdate properties

- I added the target to a container displayObject

- I tweened the container to rotate

- I tweened the wall (the blitmask target) to scroll horizontally

 

The result is that the wall AND the blitmask rotate with the container.

Is this an unexpected result? Well, I thought it was not possible, but I tried and it worked... and it looks pretty smooth too.

What do you think Carl?

Link to comment
Share on other sites

But do you think it is an unexpected behaviour? Or do you think it shouldn't be used that way? I thought BlitMask could work with straight rectangles only, but this result tells the opposite.

 

the code is this:

private var blitMaskWall : BlitMask;
private var wallBM : Bitmap;
wallBM = new Bitmap(new PatternWall(), "auto", false);
blitMaskWall = new BlitMask( wallBM, wallBM.x, wallBM.y, wallBM.width*3, wallBM.height, false, true, 0x00000000, true);
blitMaskWall.wrapOffsetY = 1; //to avoid the wrap glitch with rotation
container.addChild(wallBM);
TweenLite.to(container, 10, {rotation: 60, onUpdate:***} );
...onUpdate:
wallBM.x -= wallShift;

I didn't expect the blitmask rotated with the target, but it does.

Link to comment
Share on other sites

From what I gather, everything is working exactly as it should. The BlitMask is just a Sprite that always sits in the same container as the target, and serves as a rectangular mask. So if you rotate the parent/container, yes, everything would rotate because it's all inside there (including the BlitMask Sprite). 

 

(or maybe I'm misunderstanding your question?)

Link to comment
Share on other sites

Uh, ok, so it is the right behaviour: I thought that BlitMask was constrained to straight rectangles, and that it couldn't be rotated because of limitations to regular (not rotated) memory areas.

Ok, I misunderstood, maybe because I have never seen an example with a rotated BlitMask.

This is a very good news because it opens new perspectives for my projects! Thank you Carl and Jack!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...