FlxControl.player1.setJumpButton 无法按预期工作



我正在为我的新项目使用 Flixel 电动工具,具体来说,我使用的是 FlxControl .
我尝试使用 FlxControl.player1.setJumpButton() 设置跳转按钮,但它不起作用。
我尝试像这样使用它:

player = new FlxSprite(FlxG.width/2 - 5);
            player.makeGraphic(10,12,0xffaa1111);
            add(player);
            if (FlxG.getPlugin(FlxControl) == null)
            {
                FlxG.addPlugin(new FlxControl);
            }
            FlxControl.create(player, FlxControlHandler.MOVEMENT_ACCELERATES, FlxControlHandler.STOPPING_DECELERATES, 1, true, false);
            FlxControl.player1.setCursorControl(false, false, true, true);
            FlxControl.player1.setJumpButton("SPACE", FlxControlHandler.KEYMODE_PRESSED, 200, FlxObject.FLOOR, 250, 200);
            FlxControl.player1.setBounds(16, 0, 288, 240);
            FlxControl.player1.setMovementSpeed(400, 0, 100, 200, 400, 0);
            FlxControl.player1.setGravity(0, 400);

注意:箭头键(左和右(按预期工作。
编辑:
github.com 的完整 PlayState.as 代码:Github PlayState.as 代码

问题出在您的update()函数中。您需要在FlxG.collide()之前致电super.update()

override public function update():void
{
    super.update();
    FlxG.collide(player, level);
}

您发布的代码看起来不错。我的猜测是,问题出在您试图跳出的平台上。要确定,我必须查看您创建平台的代码。

您告诉 FlxControl 只允许玩家在触摸 FLOOR 类型的 FlxObject 时跳跃。玩家是否站在允许碰撞设置为地板或任意的对象上?

相关文档(参见"表面"参数(:

    /**
     * Enable a jump button
     * 
     * @param   key             The key to use as the jump button (String from org.flixel.system.input.Keyboard, i.e. "SPACE", "CONTROL")
     * @param   keymode         The FlxControlHandler KEYMODE value (KEYMODE_PRESSED, KEYMODE_JUST_DOWN, KEYMODE_RELEASED)
     * @param   height          The height in pixels/sec that the Sprite will attempt to jump (gravity and acceleration can influence this actual height obtained)
     * @param   surface         A bitwise combination of all valid surfaces the Sprite can jump off (from FlxObject, such as FlxObject.FLOOR)
     * @param   repeatDelay     Time delay in ms between which the jumping can repeat (250 would be 4 times per second)
     * @param   jumpFromFall    A time in ms that allows the Sprite to still jump even if it's just fallen off a platform, if still within ths time limit
     * @param   callback        A user defined function to call when the Sprite jumps
     * @param   altKey          Specify an alternative jump key that works AS WELL AS the primary jump key (TODO)
     */
    public function setJumpButton(key:String, keymode:uint, height:int, surface:int, repeatDelay:uint = 250, jumpFromFall:int = 0, callback:Function = null, altKey:String = ""):void

相关内容

  • 没有找到相关文章

最新更新