Gaming Your Way

May contain nuts.

BitmapData.copyChannel(), you're a sexy minx aren't you

There's a very minor update of X on the X Dev page.

Aside from adding some credits ( I have no sense of priority do I ? Credits done before the game, what the hell is wrong with me ) and finally getting the in-game skybox pretty much how I want it ( Although using a placeholder, which I know I'll come to love and hate having to remove come the time ) quite a bit of time ( Read: Far too much ) was spent on the transition.

Keeping with the TV screen theme, which I think I may have done to death now, I wanted the transition to be a nice distortion / break up effect ( I've been heavily inspired by this After Effects plug-in ).
Part of that, aside from the more obvious static and ghosting / blurring, was splitting up the red / green / blue channels so I could offset them.

With that in mind, copyChannel() got some F1 treatment to see how it works. It's all pretty straight forward, to the point that I'm not going to repeat the syntax here.

What isn't straight forward, is how to overlay the images again to get the original image back. Perhaps it's just me, but I couldn't find one example of how to do that ( Well, I found something using papervision which overlaid planes for a similar sort of effect ).
3 bitmaps, 1 red channel, 1 green and 1 blue. I want to shove those all into a sprite on top of each other to get the same image that I started with. To be honest, I can't think of another reason to use copyChannel() off the top of my head, so I thought I'd be tripping over examples.

But no, one PV3D example like I said, and nothing more.


The solution ? BlendMode.DIFFERENCE. By applying that to each of the 3 bitmaps it works a treat. Hopefully this will help someone out one day when faced with the same problem.
It amazes me at times how some things are still so tricky to find out about in actionscript.


Comments (6) -

  • Jon... (Techdojo)

    12/16/2008 9:23:38 AM |

    That's a VERY nice effect, I love the transition and the skybox thing is very weird, really looking forward to seeing how this game develops.


  • Squize

    12/16/2008 11:18:50 AM |

    Thanks Jon.

    I think it needs tightening up a little, I'm not happy with the blur, you can see the "border" it makes ( I've got my pre-Christmas cold so words escape me ).
    I may have to use a slightly bigger bitmap and drop a scrollRect over the top to hide that, although things like that are on the nice to have list, I really need to have a game in place :)

  • tonypa

    12/16/2008 2:34:58 PM |

    Transition looks very good :)

  • Squize

    12/16/2008 3:03:16 PM |

    Thanks a lot mate. I'm hoping the rest of the game matches it ( I'm just doing the player code atm, it's nice to have him moving around and shooting, even if it is still buggy )

  • Jeff Fulton

    12/16/2008 4:16:53 PM |

    That is the SH*T, Squize (in Californian, that means your ZarJaz rules). I can't wait to see the game that is attached to all of these amazing screens...

  • Squize

    12/16/2008 5:40:30 PM |

    Cheers mate. btw, you do know you can swear here, we are the number two search on the net for "fucking as3", from which I take a slight sense of pride :)

    There's a new update on there now, dunno if it's worth a blog post and I've got so much on atm, so I may skip it and write something about build 4.

Comments are closed