Pagz
2008-01-08, 08:31 AM
I'm trying to make a platform flash game, however I can't seem to get the character to land on the platforms, all he does is move on an invisible straight line. Since I'm very new to flash I can't seem to find where I am going wrong, if someone could point it out to me, it would be greatly appreciated, because at the moment I'm stuck.
Here is the code of the "character"
onClipEvent (load) {
xspeed = 0;
friction = .9
GroundY = _y;
Jumping = false;
JumpPower = 30;
JumpSpeed = 0;
Gravity = 3.5;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
{
this.walk = true;
this.walkdir = 'east';
this.gotoAndStop('walkeast');
this._x += 7; }
}
else if (Key.isDown(Key.LEFT)) {
this.walk = true;
this.walkdir = 'west';
this.gotoAndStop('walkwest');
this._x -= 7;
} else if (this.walkdir == 'west') {
this.walk = false;
this.gotoAndStop('facewest');
} else if (this.walkdir == 'east') {
this.walk = false;
this.gotoAndStop('faceeast'); }
{
var tmpY;
if(Jumping==true){
JumpSpeed += Gravity;
tmpY = _y + JumpSpeed;
if (Key.isDown(Key.RIGHT)) {
{
this.walk = true;
this.walkdir = 'east';
this.gotoAndStop('jumpeast');
this._x += 7; }
}
if (Key.isDown(Key.LEFT)) {
this.walk = true;
this.walkdir = 'west';
this.gotoAndStop('jumpwest');
this._x -= 7; }
if(tmpY >= GroundY){
tmpY = GroundY;
Jumping=false;
}
_y = tmpY;
}else{
if(Key.isDown(Key.UP)){
JumpSpeed = -JumpPower;
Jumping=true;
}
}
}
}
Knowing me its something very simple, but I have trouble with these things, please help. If I've left anything out, please let me know.
Here is the code of the "character"
onClipEvent (load) {
xspeed = 0;
friction = .9
GroundY = _y;
Jumping = false;
JumpPower = 30;
JumpSpeed = 0;
Gravity = 3.5;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
{
this.walk = true;
this.walkdir = 'east';
this.gotoAndStop('walkeast');
this._x += 7; }
}
else if (Key.isDown(Key.LEFT)) {
this.walk = true;
this.walkdir = 'west';
this.gotoAndStop('walkwest');
this._x -= 7;
} else if (this.walkdir == 'west') {
this.walk = false;
this.gotoAndStop('facewest');
} else if (this.walkdir == 'east') {
this.walk = false;
this.gotoAndStop('faceeast'); }
{
var tmpY;
if(Jumping==true){
JumpSpeed += Gravity;
tmpY = _y + JumpSpeed;
if (Key.isDown(Key.RIGHT)) {
{
this.walk = true;
this.walkdir = 'east';
this.gotoAndStop('jumpeast');
this._x += 7; }
}
if (Key.isDown(Key.LEFT)) {
this.walk = true;
this.walkdir = 'west';
this.gotoAndStop('jumpwest');
this._x -= 7; }
if(tmpY >= GroundY){
tmpY = GroundY;
Jumping=false;
}
_y = tmpY;
}else{
if(Key.isDown(Key.UP)){
JumpSpeed = -JumpPower;
Jumping=true;
}
}
}
}
Knowing me its something very simple, but I have trouble with these things, please help. If I've left anything out, please let me know.