PDA

View Full Version : Fall of solid ground?



santiagorook
July 31st, 2009, 04:03 PM
Flv download -http://www.mediafire.com/?li4z3ezwmz0

Ok I am just learning action script and I am making a small halo game just to practice. In the first few moments of my game I noticed that when my character jumped, when he came back down he fell. How do I fix this?

flyingmonkey456
July 31st, 2009, 04:35 PM
replace lines 42-49 in the master chief mc with this


if (jumping == true) {
vel_y -= 1;
if (vel_y<=-17) {
vel_y = 0;
jumping = false;
}
this._y -= vel_y;
}

santiagorook
July 31st, 2009, 05:04 PM
thanx, it worked!

santiagorook
July 31st, 2009, 05:52 PM
So far I am hopeless ,but learning. I want to ask you if you have the links to any tutorials on how I can have my character change positions when he is walking, jumping, falling, and shooting?

flyingmonkey456
July 31st, 2009, 07:03 PM
create a movie clip and have a different action on each frame. for animated actions such as walking, create an animated movie clip inside of the main movie clip. make sure you have frames for facing both directions.
as for the code, you'll need to declare booleans for jumping, walking, standing, and any other action, and two for facing left and right. if a key is pressed, change the variables to match the action.



if(key.isDown(key.RIGHT)){
left = false;
right = true;
if(jumping == true){
walking = false;
standing = false;
jumping = true;
}if(jumping == false){
walking = true;
standing = false;
jumping = false;
}
}


just do that for every action. for standing, click the link and read my first post.
http://www.kirupa.com/forum/showthread.php?t=330259

this is to actually perform the animations. lets say standing is frames 1 and 2, walking is 3 and 4, jumping is 5 and 6. first number is facing left, second number is facing right.



if(left == true){
if(standing == true){
gotoAndStop(1);
}if(walking == true){
gotoAndStop(3);
}if(jumping == true){
gotoAndStop(5);
}
}if(right == true){
if(standing == true){
gotoAndStop(2);
}if(walking == true){
gotoAndStop(4);
}if(jumping == true){
gotoAndStop(6);
}
}


EDIT: i'm setting up the code here a little bit differently than i did in the thread i linked to, but the concept is basically the same.