Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm making a top-down RPG for iPhone. I'm using tilemaps (CCTMXTileMap) and the cocos2d-iphone engine.

I've made a class that can handle loading maps and NPCs onto the screen, a class that handles input, and, a class that is supposed to display dialog. The dialog class takes a single string, or an array, and displays it onscreen inside a neat dialog box, hiding the controls until the user taps on the screen, when it cycles to the next message, or if it's the last/only message, hides the dialog.

My NPCs are currently stored in Core Data. Their strings will need to be updated based on quest progress. Also, there are other bits of dialog, like signposts and other messages.

So, where do I put my game's textual content? I don't think Core Data is the right place, because of three reasons:

  1. If my strings are stored in Core Data, I will probably have a harder time translating them.

  2. If my strings are in Core Data, that only leaves me with strings for NPCs (which would be attached to the NPCs in Core Data). Where does that leave everything else?

  3. If I leave my strings in Core Data, it's a bit heavy on the loading operations, no?

Given all of this background information, where do I put my strings and dialog in my game?


tl;dr

What's an efficient way to store strings for an iOS game so that they can be easily accessed, translated and referenced at various parts of the game?

share|improve this question
    
I removed your edit because that is fundamentally a separate question, and should be a separate question. –  Tetrad Nov 7 '11 at 3:35
    
See also gamedev.stackexchange.com/questions/31/… –  Tetrad Nov 7 '11 at 3:35
add comment

2 Answers 2

up vote 7 down vote accepted

Unless you have some particular requirements for portability, formatting, or speed, Apple's standard string resources should be fine.

share|improve this answer
    
+1. NSLocalizedString works just fine. Unless you want to store whole dialogue-trees, then you might need a format that supports this kind of structure. –  bummzack Jul 17 '11 at 16:46
    
And how do I "attach" them to my characters? Is there a way to reference them by number, ie string #8, or strings(8), or [strings objectAtIndex:8];? –  Moshe Jul 17 '11 at 16:53
    
The strings have keys. You should read the link. –  user744 Jul 17 '11 at 17:23
    
This is exactly what I was looking for. –  Moshe Jul 18 '11 at 1:11
    
@Moshe maybe accept this answer then? :) –  bummzack Nov 7 '11 at 8:17
add comment

I would create an external file or files for all strings. then load it once when the program begins into some global object. in run time every object that needs to display some string will have to ask that global object for the proper string. you can use keys for every string or you can use an array. if you don't like the global object idea, you can load every string whenever you need directly from file, but that may cause low fps when loading dialogues. using this approach you can easily change the language whenever you want, just you have to start reading from a different file.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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