Thank you for visiting Blazing Games

Animating Hair

As the conversation system has been covered in other articles, the game related element that will be discussed this chapter will instead be a bit more cosmetic in nature. To bring the medusian lawyer to life, I wanted to have the "snakes" on the head be animated. The animated snake-hair was done using Flash animation. The problem was all the hair was moving in uniform which was on the boring side. I wanted the hair to be more random so it would seem more alive.

One solution to add a bit of dynamic motion to the hair would be to make each strand it's own movie clip. By animating each strand separately but with a varying number of frames you can create an animation that is very dynamic as the length of the animation would then become a common multiple of the different frame lengths. creating a bunch of animations is not a difficult task but it would be time consuming. I decided to instead write a small piece of code to perform truly random animation on the hair.

public function handleFrame(evt:Event)
{
++_currentDelay;
if (_currentDelay < MOVEMENT_DELAY)
return;
_currentDelay = 0;
if (_targetFrame > currentFrame)
gotoAndStop(currentFrame+1);
else if (_targetFrame < currentFrame)
gotoAndStop(currentFrame-1);
else {
var rnd:int = _targetFrame;
while (rnd == _targetFrame)
rnd = int(Math.random() * totalFrames) + 1;
_targetFrame = rnd;
}
}

As you can see, the code simply selects a frame of animation and moves towards that frame. When it reaches that frame, another random frame is selected. Very simple yet because each hair has it’s own random frame it is heading for the overall motion is unpredictable and very slithering-like.

Previous page
Chapter 39 Page 5

About - Privacy Policy - Contact - Links - FAQ
Copyright © 2011 Blazing Games Inc. All Rights Reserved