Actionscript 3 AS3游戏-跳跃不';不改变速度

Actionscript 3 AS3游戏-跳跃不';不改变速度,actionscript-3,flash,Actionscript 3,Flash,我在让我的球员跳AS3时遇到问题。我会上传所有相关信息,我真的很难弄清楚我到底做错了什么。它过去可以工作,但现在不行了,我花了这么长时间修正错误,我不知道这是怎么搞砸的。Player类是从BoundaryObject类扩展而来的。我知道这个功能被激活是因为玩家的this.gotoAndStop(“跳跃”)工作 玩家类-跳跃功能 BoundaryObject类-重力的变量/循环 乍一看,在构造函数中设置此帧时,可能会将跳转布尔值设置为true。尝试设置父帧的向下速度 parent.downward

我在让我的球员跳AS3时遇到问题。我会上传所有相关信息,我真的很难弄清楚我到底做错了什么。它过去可以工作,但现在不行了,我花了这么长时间修正错误,我不知道这是怎么搞砸的。Player类是从BoundaryObject类扩展而来的。我知道这个功能被激活是因为玩家的
this.gotoAndStop(“跳跃”)工作

玩家类-跳跃功能

BoundaryObject类-重力的变量/循环


乍一看,在构造函数中设置此帧时,可能会将跳转布尔值设置为
true

尝试设置父帧的向下速度

parent.downwardVelocity = -28;

你把startJumping叫做哪里?你在哪里叫递增向上?什么时候将isJumping设置为false?很可能您将
BoundaryObject.downwardVelocity
Player.downwardVelocity
错误,在BO中更改前者,在
jump()中更改后者。
public var downwardVelocity:Number;
protected var isRunning:Boolean;
public var isJumping:Boolean;

public function BoundaryObject()
{

    trace("i am any object that collides with the boundary");

    downwardVelocity = 0;
    isRunning = false;

    this.gotoAndStop("jump");

    addEventListener(Event.ENTER_FRAME,enterFrameHandler);

    // constructor code
}

private function enterFrameHandler(event:Event):void
{

    downwardVelocity +=  2; //equals itself plus 2
    this.y += downwardVelocity;

}

public function incrementUpward()
{
    //increment the y up until not colliding
    this.y -= 0.1;

}

public function keepOnBoundary()
{
    downwardVelocity = 0;//stops pulling the object down

}
parent.downwardVelocity = -28;