mandag 19. oktober 2009

Case 5 - Jump and fall


Case 5 - Jump and ground by ~SveinE89 on deviantART

In this week's case our objective would be to create a jumping motion, and a ground that the character wouldn't fall straight through.

In the previous case I had already created a jumping function, using a guide i found at www.mrsunstudios.com, but now I had to look at it from another point of view. In this case we had to implement gravity to our character. And as most of us know, gravity is a force that pulls us down. In the actionscript-world, that meant that I had to move the character down, along the y-axis, every frame. So when I told the character to move up with my jump-function, the gravity then pulls him down again.

And as in real life, if there weren't any kind of ground below us, we would just keep on falling. In our group meeting on Monday, we were also introduced to the while-loops. I used this in the function that happens every frame, and used the hitTestPoint option to check if the character was hitting the ground I made. So whenever the character hit the ground, it was pushed up. With that while-loop and the gravity working together, the character could move around the ground without falling through.

Ingen kommentarer:

Legg inn en kommentar