doombom
%Europe/Berlin %430 %2008, 11:20
ik ben bezig met een project voor school we moeten een platform game (net als mario, sonic, enz). daar voor heb ik al een paar tutorials gedaan. maar ik krijg het niet voor elkaar om het karakter boven het werkblad te laten lopen op. van links naar rechts lukt wel. is er iemand die me hier mee kan helpen?onClipEvent (load) {
jumping = false;
// jumping is true
speed = 0;
// speed is 0
scoreX = _root.score._x;
//sets scoreX to the starting X postition of the "score" MC
Xpos = this._x;
//sets Xpos to the starting X postition of this MC
Ypos = this._y;
//sets Ypos to the starting Y postition of this MC
maxmove = 15;
// maxmove is fifteen(max run seed)
}
onClipEvent (enterFrame) {
_x = Xpos-_root._x;
//sets the X pos to the starting X postition of this MC
_root.score._x = scoreX-_root._x;
//sets the scire MCs X pos to its starting point on the screen
if (!_root.ground.hitTest(this._x, this._y, true) && !jumping) {
// if NOT hitting X and Y postion with the ground and NOT jumping
this._y += 6;
// Y positon moves up 6
}
if (_root.dead) {
// if dead is true
this.gotoAndStop("dead");
// goto and stop on the "dead" frame
} else {
// otherwise (if they are not dead)
speed *= .85;
// speed is multiplied by .85
// the lower the faster is slows
if (dir == "right" && !_root.leftblock.hitTest(this._x+20, this._y, true)) {
_root.score._x += speed;
// moves the score, the opposite way to the _root
this._x += speed;
// moves the char, the opposite way to the _root
_root._x -= speed;
// moves the _root
}
if (speed>0) {
//if speed is smaller than 0
dir = "right";
// the variable dir is set to right
} else if (speed<0) {
//if speed is greater than 0
dir = "left";
// the var dir is set to left
}
if (dir == "left" && !_root.rightblock.hitTest(this._x-20, this._y, true)) {
_root.score._x += speed;
// moves the score, the opposite way to the _root
this._x += speed;
// moves the char, the opposite way to the _root
_root._x -= speed;
// moves the _root
}
if (Key.isDown(Key.LEFT)) {
// if left is pressed
if (speed>-maxmove) {
// if the speed is greater than neg. maxmove
speed--;
// speed goes lower
}
this.gotoAndStop("run");
// goto and stop the run frame
this._xscale = -100;
// scale is set to neg. 100
// this is what rotates ur char
} else if (Key.isDown(Key.RIGHT)) {
// otherwise if right is pressed
if (speed<maxmove) {
// if the speed is smaller than maxmove
speed++;
// speed goes up
}
this._xscale = 100;
// scale is set to 100
// this is what rotates ur char
this.gotoAndStop("run");
// goto and stop the run frame
} else if (speed<1 && speed>-1 && !attacking) {
// if speed is smaller than one and greater than neg. 1
speed = 0;
// speed is set to 0
this.gotoAndStop("idle");
// gotoAndStop the idle frame
}
if (Key.isDown(Key.UP) && !jumping) {
// if up is pressed and NOT jumping
jumping = true;
// jumping is set true
}
if (jumping) {
// if jumping is true
this.gotoAndStop("jump");
this._y -= jump;
// Y position is set down jump
jump -= .5;
// jump is set down .5
if (jump<0) {
// if jump is smaller than 0
falling = true;
// falling is true
}
if (jump<-10) {
// if jump is smaller than neg. 5
jump = -10;
// jump is set to neg 5
// capping fall speeds prevents falling through grounds
}
}
if (_root.ground.hitTest(this._x, this._y, true) && falling) {
// if hitting X an Y postions with the ground and falling
jump = 9;
// jump is set to 9
jumping = false;
// jumping is false
falling = false;
// falling is false
}
}
}
jumping = false;
// jumping is true
speed = 0;
// speed is 0
scoreX = _root.score._x;
//sets scoreX to the starting X postition of the "score" MC
Xpos = this._x;
//sets Xpos to the starting X postition of this MC
Ypos = this._y;
//sets Ypos to the starting Y postition of this MC
maxmove = 15;
// maxmove is fifteen(max run seed)
}
onClipEvent (enterFrame) {
_x = Xpos-_root._x;
//sets the X pos to the starting X postition of this MC
_root.score._x = scoreX-_root._x;
//sets the scire MCs X pos to its starting point on the screen
if (!_root.ground.hitTest(this._x, this._y, true) && !jumping) {
// if NOT hitting X and Y postion with the ground and NOT jumping
this._y += 6;
// Y positon moves up 6
}
if (_root.dead) {
// if dead is true
this.gotoAndStop("dead");
// goto and stop on the "dead" frame
} else {
// otherwise (if they are not dead)
speed *= .85;
// speed is multiplied by .85
// the lower the faster is slows
if (dir == "right" && !_root.leftblock.hitTest(this._x+20, this._y, true)) {
_root.score._x += speed;
// moves the score, the opposite way to the _root
this._x += speed;
// moves the char, the opposite way to the _root
_root._x -= speed;
// moves the _root
}
if (speed>0) {
//if speed is smaller than 0
dir = "right";
// the variable dir is set to right
} else if (speed<0) {
//if speed is greater than 0
dir = "left";
// the var dir is set to left
}
if (dir == "left" && !_root.rightblock.hitTest(this._x-20, this._y, true)) {
_root.score._x += speed;
// moves the score, the opposite way to the _root
this._x += speed;
// moves the char, the opposite way to the _root
_root._x -= speed;
// moves the _root
}
if (Key.isDown(Key.LEFT)) {
// if left is pressed
if (speed>-maxmove) {
// if the speed is greater than neg. maxmove
speed--;
// speed goes lower
}
this.gotoAndStop("run");
// goto and stop the run frame
this._xscale = -100;
// scale is set to neg. 100
// this is what rotates ur char
} else if (Key.isDown(Key.RIGHT)) {
// otherwise if right is pressed
if (speed<maxmove) {
// if the speed is smaller than maxmove
speed++;
// speed goes up
}
this._xscale = 100;
// scale is set to 100
// this is what rotates ur char
this.gotoAndStop("run");
// goto and stop the run frame
} else if (speed<1 && speed>-1 && !attacking) {
// if speed is smaller than one and greater than neg. 1
speed = 0;
// speed is set to 0
this.gotoAndStop("idle");
// gotoAndStop the idle frame
}
if (Key.isDown(Key.UP) && !jumping) {
// if up is pressed and NOT jumping
jumping = true;
// jumping is set true
}
if (jumping) {
// if jumping is true
this.gotoAndStop("jump");
this._y -= jump;
// Y position is set down jump
jump -= .5;
// jump is set down .5
if (jump<0) {
// if jump is smaller than 0
falling = true;
// falling is true
}
if (jump<-10) {
// if jump is smaller than neg. 5
jump = -10;
// jump is set to neg 5
// capping fall speeds prevents falling through grounds
}
}
if (_root.ground.hitTest(this._x, this._y, true) && falling) {
// if hitting X an Y postions with the ground and falling
jump = 9;
// jump is set to 9
jumping = false;
// jumping is false
falling = false;
// falling is false
}
}
}