mardi 17 février 2015

show keyboard on SKNode touch


Vote count:

0




I am trying to do a registration scene inside a game on iOS. what I have so far is this:


Game Registration Scene


Since I couldn't manage to put UITextField inside the Scene that I have, I tried to put SKNodes that activate the keyboard on touch. It would be very useful if someone could help me to put UITextFields inside my game scene (because it would be easier to get a registration scene, and with less code, and also with native support for this).


My code so far is this:



let nameForm:SKSpriteNode = SKSpriteNode(imageNamed: "RegistrationScene_TEST_textviews")
let usernameForm:SKSpriteNode = SKSpriteNode(imageNamed: "RegistrationScene_TEST_textviews")
let passwordForm:SKSpriteNode = SKSpriteNode(imageNamed: "RegistrationScene_TEST_textviews")
let passwordForm2:SKSpriteNode = SKSpriteNode(imageNamed: "RegistrationScene_TEST_textviews")


And when someone touch any of these nodes it should be managed with a method like this:



override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
let touch = touches.anyObject()! as UITouch
let location = touch.locationInView(self.view)

for touch:AnyObject in touches{
if CGRectContainsPoint(nameForm.frame, touch.locationInNode(self)){
//Function to display the keyboard
//Function that saves the keystroke
//Function to display a nameLabel with the saved keystroke
}
//same for the other Forms

//methods for the buttons (DONE)
}
}


If there is any other way to achieve a text input into the game (to save game statistics or something useful for the gameplay) please let me know, any help would be very appreciated



asked 1 min ago







show keyboard on SKNode touch

Aucun commentaire:

Enregistrer un commentaire