cocos-docs icon indicating copy to clipboard operation
cocos-docs copied to clipboard

快速上手:制作第一个游戏

Open ablupi opened this issue 1 year ago • 0 comments

URL : https://github.com/cocos-creator/creator-docs/blob/master/zh/getting-started/first-game/index.md

文档在“添加游戏结束逻辑”这一步骤时,新增了onOnceJumpEnd函数,却没有进行调用,导致无法监听到跳跃结束的事件,进而无法进入到游戏结束的逻辑中。需要在“添加游戏结束逻辑”这一步骤的中添加对onOnceJumpEnd函数的调用,或许新增以下代码能解决问题:

    update (deltaTime: number) {
        if (this._startJump) {
            this._curJumpTime += deltaTime;
            if (this._curJumpTime > this._jumpTime) {
                // end
                this.node.setPosition(this._targetPos);
                this._startJump = false;
                this.onOnceJumpEnd();    // 调用onOnceJumpEnd函数
            } else {
                // tween
                this.node.getPosition(this._curPos);
                this._deltaPos.x = this._curJumpSpeed * deltaTime;
                Vec3.add(this._curPos, this._curPos, this._deltaPos);
                this.node.setPosition(this._curPos);
            }
        }
    }

ablupi avatar Jul 28 '22 09:07 ablupi