2
\$\begingroup\$

I am trying to learn SpriteKit and play with some simple sample apps.

Currently I am trying to achieve below things:

  1. Show keyboard over SKScene
  2. If user taps 'A', perform some action on a sprite node, if user taps 'B' perform some other action on other sprite nodes

I tried to google 'Showing keyboard over SKScene' but could not get any suitable answer :(

Any clues or suggestions?

\$\endgroup\$
2
  • \$\begingroup\$ When you say "Show keyboard over SKScene" are you referring to displaying a keyboard on the screen so that keys turn a certain colour if they are pressed or something like that? As for your second point, that's fairly easy. In SKScene's there's a method called keyDown: and keyUp:. Create keyDown as -(void) keyDown:(NSEvent *)theEvent {}. You can use the argument theEvent.keyCode to get the numeric value of whatever key was pressed. \$\endgroup\$
    – 02fentym
    Commented Aug 24, 2015 at 22:26
  • \$\begingroup\$ I meant to say the same way it appears when we tap on a text field \$\endgroup\$
    – Devarshi
    Commented Aug 25, 2015 at 12:37

1 Answer 1

1
\$\begingroup\$

I think your should implement UIKeyInput protocol for your relevant view, set the view's canBecomeFirstResponder to true. When you need the keyboard, just call

view.becomeFirstResponder
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .