There was a small bug inside the TextField code with regards to accessing the latest strings in textFieldUpdated method. The protocol has been adapted to reflect this.
Updates are available here.
Enjoy!
Showing posts with label uitextfield. Show all posts
Showing posts with label uitextfield. Show all posts
Friday, November 27, 2009
Wednesday, November 25, 2009
The Quest to implement a custom Text Field
To match the UI of the App I'm working on right now, I needed a text field with a custom look and feel that would nicely integrate with cocos2d.
I thought there must've been someone out there who has already accomplished / implemented something like this but after a while of google'ing and browing the cocos2d forums, I figured that there seems to be no final, working source code of something like this available.
With some help from this post by Jack and David (and some other stuff I don't seem to be able to remember), I eventually managed to code something myself which combines the rendering abilities of cocos2d (Sprites and BitmapFontAtlas) with the input capabilities of UITextField. This sure feels like a hack as I'm using an "invisible" (read: very tiny) UITextField to handle the text input while rendering the intercepted text using BitmapFontAtlas and some other Sprites but - hey - it works just fine.
I'll check with the people at cocos2d whether it would be worthwhile to include such a class in the main distribution. In the meantime, the files are available here.
Here's how you'd use the TextField class in your own projects:
Hope this gets you going much quicker than me! Now enjoy the code and let me know what you think!
I thought there must've been someone out there who has already accomplished / implemented something like this but after a while of google'ing and browing the cocos2d forums, I figured that there seems to be no final, working source code of something like this available.
With some help from this post by Jack and David (and some other stuff I don't seem to be able to remember), I eventually managed to code something myself which combines the rendering abilities of cocos2d (Sprites and BitmapFontAtlas) with the input capabilities of UITextField. This sure feels like a hack as I'm using an "invisible" (read: very tiny) UITextField to handle the text input while rendering the intercepted text using BitmapFontAtlas and some other Sprites but - hey - it works just fine.
I'll check with the people at cocos2d whether it would be worthwhile to include such a class in the main distribution. In the meantime, the files are available here.
Here's how you'd use the TextField class in your own projects:
Hope this gets you going much quicker than me! Now enjoy the code and let me know what you think!
Labels:
cocos2d,
iphone,
text field,
textfield,
ui,
uitextfield
Subscribe to:
Posts (Atom)