00:00
00:00
Newgrounds Background Image Theme

Ryzmik just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

I need help with my platformer

391 Views | 2 Replies
New Topic

I need help with my platformer 2010-12-03 20:51:23


Ok so i'm working on making a platformer game for my first flash. I'm having some problems with making my character do a walking animation correctly. FLASH says there are no problems with the script and everything works except that one part.

Heres the code::

onClipEvent (load) {
var ground:MovieClip = _root.ground;
var grav:Number = 0;
var gravity:Number = 2;
var speed:Number = 5;
var maxJump:Number = -18;
var touchingGround:Boolean = false;
facing = 1;
}
onClipEvent (enterFrame) {
_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)) {
facing = 1;
this.gotoAndPlay(3);
_x += speed;
} else {
if (facing == 1) {
this.gotoAndStop(1);
} else if (facing == 2) {
this.gotoAndStop(2);
}
}
if (Key.isDown(key.LEFT)) {
facing = 2;
this.gotoAndPlay(4);
_x -= speed;
} else {
if (facing == 1) {
this.gotoAndStop(1);
} else if (facing == 2) {
this.gotoAndStop(2);
}
}
if (Key.isDown(key.UP) && touchingGround) {
grav = maxJump;
}
}

Response to I need help with my platformer 2010-12-03 20:53:41


Your question can be better answered in the flash forum, there are animators who hang out there who can better answer your problem.


Wi/Ht regular|Elite Guard Barracks Member|Idiot-Buster-Elite Guard Sup. Commander

BBS Signature

Response to I need help with my platformer 2010-12-03 21:03:03


Yes, as I-B states, please ask Actionscript and Flash related questions in the Flash Forum.


Rev 22:20 || Wi/Ht? # 46 || Why was my review deleted? || Without her, we are lifeless satellites drifting.

BBS Signature