I'm using Flixel Power Tools for my new project, to be specific I'm using FlxControl
.
I tried to set a Jump button using FlxControl.player1.setJumpButton()
, but it does not work.
I tried using it like this:
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);
Note:The arrow keys(left & right) are working as expected.
Edit:
Full PlayState.as code at github.com : Github PlayState.as code
The problem is in your update()
function. You need to call super.update()
before FlxG.collide()
:
override public function update():void
{
super.update();
FlxG.collide(player, level);
}