Hi!
How can I manipulate the behavior “PlatformObject” using a javascript code event?
This is what I make but it does not work when I add the action for simulate Keys for movement. I’ve just follow what it is in the wiki docs.
I will appreciate any ideas.
const player = runtimeScene.getObjects(“PlayerGreen”);
const playerHitBoxes = runtimeScene.getObjects(“PlayerHitBox”);
const player1 = player[0];const platformerBehavior = playerHitBoxes[0].getBehavior(“PlatformerObject”);
if (platformerBehavior.isJumping() || platformerBehavior.isFalling()){
player1.setAnimation(1);
} else if (platformerBehavior.isOnFloor()) {
if (!platformerBehavior.isMoving()) {
player1.setAnimation(0);
} else {
player1.setAnimation(2);
};
};var LEFTKEY = 37;
var RIGHTKEY = 37;
if (runtimeScene.getGame().getInputManager().isKeyPressed(LEFTKEY)) {
player1.flipX(true);} else if (runtimeScene.getGame().getInputManager().isKeyPressed(RIGHTKEY)) {
player1.flipX(false);
}
if (keyboard.isKeyPressed(LEFTKEY)) {
** playerHitBoxes.simulateLeftKey**
}
//JUMP (?)
/if(runtimeScene.getGame().getInputManager().isKeyPressed(Spacebar)){
** playerHitBoxes._jumpKey = true;*