Vector Grafix Animation Studios

REVOLUTIONISING THE PRESENT....

Blog

Action script for char movements(platformer)

Posted by CRYBORG on May 10, 2014 at 8:00 PM

HERE'S A LITTLE HELP FOR THE FLASH DEVOLOPERS!!

YOU CAN GET FREE ACTION SCRIPTS OR CODES FROM OUR SITE 

HERE ARE THE CODES FOR ONE THE MOST POPULAR GAME GENRE,PLATFORMER(ONLY FOR THE "CHAR")

onClipEvent (load) {

var ground:MovieClip = _root.ground;

var grav:Number = 0;

var gravity:Number = 2;

var maxspeed:Number = 10;

var xspeed:Number = 0;

var acceleration:Number = 2;

var maxJump:Number = -15;

var friction:Number = 0.9;

var yspeed:Number = 0;

var bounce:Number = -0.9;

var touchingGround:Boolean = false;

}

onClipEvent (enterFrame) {

xspeed *= friction;

if (Math.abs(speed) < 0.3) {

xspeed = 0;

}

_y += grav;

grav += gravity;

while (ground.hitTest(_x, _y, true)) {

_y -= gravity;

grav = 0;

}

if (ground.hitTest(_x, _y+5, true)) {

touchingGround = true;

} else {

touchingGround = false;

}

if (Key.isDown(Key.RIGHT)) {

if ( xspeed < maxspeed ) {

xspeed += acceleration;

 

}

}

if (Key.isDown(Key.LEFT)) {

if ( Math.abs(xspeed) < maxspeed ) {

xspeed -= acceleration;

}

}

if (Key.isDown(Key.UP) && touchingGround) {

grav = maxJump;

}

if (ground.hitTest(_x+(_width/2), _y-(_height/2), true)) {

acceleration = -2;

xspeed = 0;

xspeed += acceleration;

_x += xspeed ;

}else{

acceleration = 2;

}

if (ground.hitTest(_x-(_width/2), _y-(_height/2), true)) {

acceleration = -2;

xspeed = 0;

xspeed -= acceleration;

_x += xspeed ;

}else{

acceleration = 2;

}

if (ground.hitTest(_x-(_width/2), _y-(_height/2), true)) {

_x += xspeed;

}

if (ground.hitTest(_x, _y-(height), true)) {

grav = 3;

}

_x += xspeed;

}

If you recieve any errors, inform us because all the codes are tested before publishing 

NOTE : YOU CAN ALSO GET ACTION SCRIPT OR THE CODES ON DEMAND,ALL YOU NEED TO DO IS TO SIGN UP AT OUR SITE AND PLACE AN ORDER UNDER "DOWNLOAD OR ORDER SECTION"

Categories: None

Post a Comment

Oops!

Oops, you forgot something.

Oops!

The words you entered did not match the given text. Please try again.

Already a member? Sign In

0 Comments