Reputation: 21
I am new to programming in general and have been pursuing it as a hobby for about three months. I have basic understanding of swift and Xcode but I cannot figure out a way to add text boxes to the game I am making. As a work around (the long way around), I've created my own text boxes with a white rectangle as an SKShapeNode and blinking my own cursor and setting its position to the string length of text and recording keyEvents and translating them into functions such as deleting and tabbing, etc. Is there an easier way or will I have to do this when I want a text box?
Upvotes: 2
Views: 651
Reputation: 159
One way is to use a UITextView - its pretty easy to use, something like:
UITextView *tv = [[UITextView alloc]initWithFrame:CGRectMake(0, 0, 50, 50)]];
then set any other properties and then within you Scene add it like:
[self.scene.view addSubview:tv];
The samples above are all obj-c but easy to convert to swift
Upvotes: 1