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\$
  • \$\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 Aug 24 '15 at 22:26
  • \$\begingroup\$ I meant to say the same way it appears when we tap on a text field \$\endgroup\$ – Devarshi Aug 25 '15 at 12:37
0
\$\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\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.