At 9/11/09 04:46 AM, Logidude wrote:
Can anybody help me? This is a game with game play like Castle Crashers or Portal Defenders.
Stop being so impatient.
At 9/11/09 04:31 AM, Logidude wrote:
Hello. I need some help programming. I want to make it so that when I press the space bar it plays the attack (right now it is walking animation) once and then goes back to the standing animation.
You'll need a third frame in the "kid" MC, which will be the attack animation. On the last frame of the attack animation, put:
_root.player.fight = false;
_parent.gotoAndStop(1);
And replace the code you have on the "kid" MC, with:
onClipEvent (load) {
var speed:Number = 7;
var speed2:Number = 7;
var scale:Number = _xscale;
var fight:Boolean = false;
}
onClipEvent (keyUp) {
if (!fight) {
this.gotoAndStop(1);
}
}
onClipEvent (keyDown) {
if (Key.getCode() == Key.SPACE) {
this.gotoAndStop(3);
fight = true;
}
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
this._y -= speed2;
this.gotoAndStop(2);
}
if (Key.isDown(Key.DOWN)) {
this._y += speed2;
this.gotoAndStop(2);
}
if (Key.isDown(Key.LEFT)) {
this._x -= speed;
this.gotoAndStop(2);
_xscale = -scale;
}
if (Key.isDown(Key.RIGHT)) {
this._x += speed;
this.gotoAndStop(2);
_xscale = +scale;
}
thisDepth=this.getDepth(), otherDepth=_root.enemy.getDepth();
if (_y>_root.enemy._y && otherDepth>thisDepth) {
this.swapDepths(_root.enemy);
}
if (_root.enemy._y>_y && thisDepth>otherDepth) {
this.swapDepths(_root.enemy);
}
if (ground.hitTest(_x+(_width/2), _y-(_height/2), true)) {
_x += speed;
}
if (ground.hitTest(_x-(_width/2), _y-(_height/2), true)) {
_x -= speed;
}
}
You're code was a mess, so I tidied it up. And I don't see the point of half of it, but meh.
- Good practice to declare variables properly.
- You only need one enterFrame clipEvent
And as for the black bar "thing", I might look at that later. I would upload a fla, but I think its better if you learnt for yourself.