Friday 27 May 2011

Character movement

I'll stick to explaining the key points here or else it'll get confusing.
On the down button press, Calvin switches to facing forwards.
On the up button press, Calvin switches to facing backwards.
On the left button press, Calvin switches to facing left.
On the right button press, Calvin switches to facing right.
This is done through gotoAndStop codes. 

When Calvin gets 200 pxls to the left/right of the screen, 
the background starts scrolling with the movement of Calvin.

In this chunk of code there's parts that mention wellies which might look confusing to someone else looking at this.
This is here because in the barn you can click on the wellies and Calvin will wear them,
you can't walk through the mud until you wear these. 
The wellies are always on Calvins feet, but on alpha=0 
Calvin wears the wellies when the alpha = 1 and he is then able to pass the coordinate cut off point where the mud is.

There's also a part about ladders,
when ladders2 alpha =0 , on the up key press Calvin can go up the ladders.
The left and right keys are disabled when Calvin goes up the ladders as Calvin just goes invisible when the ladder animation occurs.
(It'd look pretty strange if Calvin stayed at the bottom of the ladders,
while a seperate animation of him was climbing up the ladders at the same time!)
When Calvin gets to the bottom of the ladders (animation over) Calvin reappears on the main stage
and his left and right movement is free to move again.

No comments:

Post a Comment