0

我在让我的 Player 在 AS3 中跳转时遇到问题。我会上传所有相关的东西,我真的很难弄清楚我做错了什么。它曾经可以工作,但现在不行了,我花了很长时间修复错误,我无法弄清楚这是哪里搞砸了。Player 类是从 BoundaryObject 类扩展而来的。我知道该功能已被激活,因为播放器的this.gotoAndStop("jump");作品。

播放器类 - 跳转功能

public function startJumping():void
{
    if (isJumping == false)
    {

        isJumping = true;
        this.gotoAndStop("jump");
        downwardVelocity = -28;
    }
}

BoundaryObject 类 - 重力的变量/循环

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

}
4

2 回答 2

0

尝试设置父级的 downVelocity。

parent.downwardVelocity = -28;
于 2013-04-26T14:21:48.423 回答
0

乍一看,true当您在构造函数中设置此框架时,可能会将您的跳转布尔值设置为。

于 2013-04-26T10:19:29.890 回答