Indie Dev

Hello Guest!. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, sell your games, upload content, as well as connect with other members through your own private inbox!

Input.isPressed('up') is correct?

Status
Not open for further replies.
I'm looking for some code that shows how to use Input.isPressed('up') or ('left') or ('right') or ('down') etc...
What commands can I put in the (' ') and why isn't this working?
p, li { white-space: pre-wrap; }



if (Input.isPressed('right') && Input.isPressed('down') && Input.isPressed('left'))

{ $gameMessage.setBackground(1);

$gameMessage.setPositionType(2);

$gameMessage.add("Blitz Activated: Aura Storm >All Enemies -1000HP");

$gameTroop.members()[1].startAnimation(185, false, delay15);

$gameTroop.members()[1].gainHP(-1000);

} else {

$gameMessage.setBackground(1);

$gameMessage.setPositionType(2);

$gameMessage.add("Incorrect Blitz Combo"); }
[doublepost=1447399638,1447399550][/doublepost]It doesn't crash but it is only accepting the else handler every time. So I can't even test the IF statement's contents.
 

eivl

Local Hero
Xy$
0.00
You can use my keyboard plugin, it has this functionality already.

Input.isPressed('up') or ('left') or ('right') or ('down')
here you use or

if (Input.isPressed('right') && Input.isPressed('down') && Input.isPressed('left'))
here you use and

It doesn't crash but it is only accepting the else handler every time. So I can't even test the IF statement's contents.
you are checking if you press "right" and "down" and "left" at the same time.
if this is intended then it should work, but since keyPressed triggers one time pr frame, i am not sure that pressing three buttons will register correctly. check it out!
 
JavaScript:
if(Input.keyPressed("M") && Input.keyPressed("V") &&
$gameSwitches(102, false)){
   $gameSwitches.setValue(101, true);
}
object is not a function error.
How do say in javascript: if game switch is off and these keys are being pressed then do this?
 

eivl

Local Hero
Xy$
0.00
JavaScript:
if (!!$gameSwitches.value(1)){
console.log("Switch 1 is off");
}
you should only use 1 parameter to $gameSwitches.value since it will return true or false

makes sense?

have you tested if pressing multiple buttons work?
JavaScript:
if(Input.keyPressed("M")&& Input.keyPressed("V")){
   console.log("Two keys pressed");
}
i am not sure that will work...
 

Bizarre Monkey

I SHALL BE GLORIOUS!
@eivl: I'm looking forward to developing PFC with your keyboard input. Is there a way I can check if it's in use via an event condition?

Oh derp, nevermind. I didn't have the plugin installed. Hahahaha.
 
Status
Not open for further replies.
Top