PDA

View Full Version : Platform scroller animation help



DangerousDan
August 29th, 2006, 01:22 PM
I have my animations going pretty good so far, the only problem is when one of them interupt each other. I have a piece of code inside the movie clip after the animation to tell me when the animation is done. After the slashing animation it has
_root.char.slashing = false; after the shooting animation it has
_root.resetShot(); Which is basically the same thing as shooting = false, I had just written the function on the frame instead of the character at the time.
SWF:
http://brinkmanweb.com/rpg/dan/flash/platformScroller.html
Char MC:

onClipEvent (load) {
jumping = false;
speed = 1;
maxmove = 10;
jump = 0;
running = false;
falling = false;
dir = true; // true right, false left
guns = true;
shooting = false;
shootA = false;
slashing = false;
i = 0;
}
onClipEvent (enterFrame) {
if (this._y-(this._height*2) != Stage.height-(this._height*2) && !jumping) {
this._y += 6;
}
if (_root.dead) {
this.gotoAndStop("dead");
} else {
if(Key.isDown(65) and 0+speed+(this._width/2) <= this._x and !jumping and !slashing){
dir = false;
this._x-=speed;
//_root._x += speed;
if(speed < maxmove){
speed += .5;
}
this._xscale = -100;
if(!running and !shooting){
this.gotoAndPlay("running");
running = true;
}
}
if(Key.isDown(68) and Stage.width-speed-(this._width/2) >= this._x and !jumping and !slashing){
dir = true;
this._x+=speed;
//_root._x -= speed;
if(speed < maxmove){
speed += .5;
}
this._xscale = 100;
if(!running and !shooting){
this.gotoAndPlay("running");
running = true;
}
}
if (Key.isDown(87) && !jumping) {
jumping = true;
}
if (jumping) {
this.gotoAndStop("jumping");
this._y -= jump;
jump -= .5;
if(this._x + speed <= Stage.width - (this._width/2) and dir){
this._x += speed;
}
else if(0+speed+(this._width/2) <= this._x and !dir){
this._x -= speed;
}
if (jump<0) {
falling = true;
}
if (jump<-15) {
jump = -15;
}
}
if (this._y-(this._height*2) == Stage.height-(this._height*2) && falling) {
jump = 7;
jumping = false;
falling = false;
}
if(Key.isDown(70)){
if(guns){
guns = false;
_root.weaponHUD.gotoAndStop("sword");
}
else if(!guns){
guns = true;
_root.weaponHUD.gotoAndStop("guns");
}
}
if(Key.isDown(Key.SPACE) and !shooting and guns){
shooting = true;
_root.shoot(dir);
this.gotoAndPlay("shoot");
}
if(Key.isDown(Key.SPACE) and !slashing and !guns and !jumping){
slashing = true;
this.gotoAndPlay("slash");
}
if(!Key.isDown(65) and !Key.isDown(68) and !Key.isDown(87) and !Key.isDown(Key.SPACE)){
if(!jumping and !shooting and !slashing){
this.gotoAndStop("idle");
}
if(speed > 0 and !jumping){
speed -= 1;
}
running = false;
}
}
}

_root's code

_root.dead = false;
stop();
function resetShot(){
char.shooting = false;
}
function shoot(dir){ //Fire pistols
i = getNextHighestDepth();
_root.attachMovie("bullet","bullet"+i , i);
_root["bullet"+i].dir = dir;
_root["bullet"+i]._x = char._x;
_root["bullet"+i]._y = char._y - char._height/2 - 10;
_root["bullet"+i].onEnterFrame = function(){
if(this.dir){
this._xscale = -100;
this._x += 13;
}
else if(!this.dir){
this._xscale = 100;
this._x -=13;
}
if(this._x > Stage.width or this._x < 0){
this.removeMovieClip();
}
}
}

Holmesc
September 2nd, 2006, 09:10 PM
Ummm, I don't know how to help you, but make your guy go faster. It's like he's fat or something....