Test with fun how much you know about Art4.01 / 5.00 12,119 Views
Challenge hordes of ninjas in this epic action adventure game.4.14 / 5.00 43,842 Views
Help strange creatures to bring the eye to a mysterious customer.3.73 / 5.00 14,876 Views
I recently learned about the displacement map filter, and was like "cool, I should use that somehow".
So just for fun I decided to implement it in my current project's main menu.
Basically the background is a texture, programmed to scroll with the mouse direction. This done using begin bitmap fill and a transform matrix.
So far so good.
This background is then drawn onto a blank bitmap data object, and then tinted red for some reason.
(well because I was trying to get it to work, and while there is no good reason for it, I'm too lazy to change it back)
Anyway, part of logo then warps itself to the texture, using data I just made as it's map.
The problem is that instead of warping at all, the logo just "shakes" rapidly a few pixels. I've spent a few hours tweaking and playing with it, It doesn't seem to want to warp no matter what I do :( and to add insult to injury, there's nothing on google about this specific issue either.
My map, while mostly red, does have color variants so I see reason why it wouldn't warp a little.
tint = new ColorTransform(0, 1, 0, 0, 250, 0, 0, 0, 0); Mapbit.draw(_root.Background.Ass, new Matrix(), tint); var mapPoint:Point = new Point(_root.Mania._x-(_root.Mania._width/2), _root.Mania._y-(_root.Mania._height/2)); var componentX:Number = 1; var componentY:Number = 1; var scaleX1:Number = 10; var scaleY1:Number = 10; var filter:DisplacementMapFilter = new DisplacementMapFilter(Mapbit, mapPoint, componentX, componentY, scaleX1, scaleY1); Mania.filters = [filter];
Note: Mania is the instance name of part of the logo I'm trying to warp.
Alright so I just did a little experiment to make sure it wasn't how I was applying the filter.
Turns out the reason it jumps around has something to do with the way the timeline was set up. For each main loop, I usually have an onEnterFrame function key frame, then a few blank frames and a gotoandplay that returns the play head back to the onEnterFrame. Instead, by just having one key frame, it works perfectly as expected.
That doesn't explain why is didn't work at all though ...
In my experiment I recreated the jumping around issue, but the filter still worked on certain frames.
Now my question is, is there a work around for this? I really don't want to restructure my entire game for one filter effect, and probably wont ...
Alright, I just about solved it. The jumping is related to the gotoAndPlay, or the play head moving at all.
Simply adding a stop function fixes it.