How to use numpad? [b368]

NobodyX

  • *
  • Posts: 1228
I can't use numpad controls, apparently Flixel doesn't recognize them. Not using the number pad is not an option, what do I do?

Will this be fixed in StencylWorks sometime?

« Last Edit: March 18, 2011, 10:08:28 am by Greg »

irock

  • *
  • Posts: 2891
Why would you want to use the number pad? Most laptops don't have them, so they wouldn't be able to play your game.

NobodyX

  • *
  • Posts: 1228
Because I am making a fighting game and it would be very easy to stick a multiplayer mode in, but it won't make much sense if peoples hands are squished together just because the right end of the keyboard arbitrarily cannot be used.

Darkhog

  • Posts: 1243
1p: w,s,a,d z,x,c
2p: up,down,left,right /,>,<

?


Of course this is still valid, because I casn see that in some cases NUMPAD would do better (cheat codes when normal numbers need to be used, entering "passwords" in game, etc.)

There are no impossible things. There is only lack of skills.
Don't click this if your computer has less than 641 kilobytes of RAM.
Stencyl stencyling stencylish stencylers :D

Jon

  • *
  • Posts: 17524
Flixel supports these keys as FlxKeyboard.ONE, TWO, THREE, etc.

NobodyX

  • *
  • Posts: 1228
1p: w,s,a,d z,x,c
2p: up,down,left,right /,>,<
That would be extremely awkward to have overlapping hand, and wouldn't even be appropriate because the game will have 5 or 6 non-directional buttons per player.

Flixel supports these keys as FlxKeyboard.ONE, TWO, THREE, etc.
And the fact that entering number pad controls in StencylWorks doesn't work will be fixed, right?

Anyway, I tried setting a control attribute with a code mode block reading:
_A1Button = "FlxKeyboard.ONE";

I also tried it without the "FlxKeyboard." part, neither work although it does work when fine if I choose other controls. I'm obviously not a programmer, so I have no idea what else to try.

Jon

  • *
  • Posts: 17524
What I said represents a boolean, so you'd use it inside an if block.

//Means that the 1 key is pressed.
if(FlxKeyboard.ONE)
{
}

I can put in a request to look into what's preventing numbers from being entered into the controls editor, but I can't guarantee anything at this point.

NobodyX

  • *
  • Posts: 1228
What I said represents a boolean, so you'd use it inside an if block.

//Means that the 1 key is pressed.
if(FlxKeyboard.ONE)
{
}

This works:
if (!isKeyDown(_DownButton))
{
g.fillRect(0, 0, 10, 10);
}

But this makes it say there are fields with bad data upon compiling:
if(FlxKeyboard.ONE)
{
g.fillRect(0, 0, 10, 10);
}

Am I doing it wrong or is something broken?

Jon

  • *
  • Posts: 17524
You'd need to use the check syntax button in design mode (it's in one of the top tabs) to see what the error actually is.

One more thing you could try is:

if(org.flixel.data.FlxKeyboard.ONE)
{
}

NobodyX

  • *
  • Posts: 1228
That doesn't work either.
Here's what comes up when checking syntax for each:


Behavior: Design_35_35 at line 219
Access of undefined property data in package org.flixel.
      if(org.flixel.data.FlxKeyboard.ONE)

...and...

Behavior: Design_35_35 at line 219
Access of undefined property FlxKeyboard.
      if(FlxKeyboard.ONE)

Jon

  • *
  • Posts: 17524
No idea in that case. The org.flixel.data approach should work without a problem and has worked for others doing things that required using classes we don't expose directly by default.

This will need to wait until the weekend, or until another dev stops by for a recommendation.

Hectate

  • *
  • Posts: 4643
IIRC, FlxG holds the relevant keyboard presses in an accessible manner...

if ( FlxG.keys.pressed("ONE"))
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

NobodyX

  • *
  • Posts: 1228
IIRC, FlxG holds the relevant keyboard presses in an accessible manner...

if ( FlxG.keys.pressed("ONE"))
The game launches without an error, but apparently this is for the non-numpad 1 and not the numpad 1.

Hectate

  • *
  • Posts: 4643
Sorry, I neglected to note that my answer was geared toward the problem of how to access the keys rather than the specific keys needing accessed.

flixel.org/forums/index.php?topic=1883.0

This thread seems to indicate that "NUMPAD" should be part of the string to reference the keys in question. Unfortunately it doesn't detail which version cai referenced in his post, so I can't guarantee that Stencyl's version supports those values. Good luck!

Note: Additonal details concerning the other ways to check on keyboard input can be found at the following link.

flashgamedojo.com/wiki/index.php?title=Keyboard_Input_(Flixel)
:
:
Patience is a Virtue,
But Haste is my Life.
Proud member of the League of Idiotic Stencylers; doing things in Stencyl that probably shouldn't be done.

NobodyX

  • *
  • Posts: 1228
if ( FlxG.keys.pressed("NUMPADONE"))
and other similar things unfortunately do not work.

Anyway, thanks for the help so far Jon and Hectate.