I am working on a children’s book app and would like to dynamically populate speech bubble(s) for character dialogues on every scene. I got the animation and dialogue working and below is the code for that. I would have multiple pages in my book, every page would have multiple characters and every character would have multiple dialogues. What is the best way to make this a generic approach so I can use it repeatedly. Can I store the dialogues in TEXT/XML file and read and display them dynamically based on following parameters: Page number, Character number, dialogue number?
UIImage *bubble = [[UIImage imageNamed:@"BubbleLefthand.png"]
resizableImageWithCapInsets:UIEdgeInsetsMake(15, 21, 15, 21)];
UIImageView *imgView = [[[UIImageView alloc] initWithImage:bubble] autorelease];
imgView.frame = CGRectMake(250, 350, 0, 0);
UILabel *xlabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
xlabel.text = @"This is a dialogue text!!!";
[imgView addSubview:xlabel];
[self.view addSubview:imgView];
[UIView animateWithDuration:0.5
animations:^(void) {
imgView.frame = CGRectMake(250, 350, 300, -40);
xlabel.frame = CGRectMake(30, 10, 200, 20);
} completion:^(BOOL finished) {
STLog(@"ChildrenBookViewController ==> SPPECH BUBBLE ANIMATION COMPLETE. Switch Case: %d", pageNum);
}];
Currently my dialogue shows like attach screenshot.

As for organizing the dialogs, organizing by page at the highest level seems fine. You can define background image as an attribute of the page.
At one level below page, I think it is better to define “event”. Each event correspond to an action from user, or you may even define an event that automatically follows the previous event.
In each event, you can have different types: show dialogue, hide dialogue, control the background music, control sound effect.
For show/hide dialogue event, dialogue id should be defined (the dialogue can be placed directly here or collected in a separate file), plus the direction of the bubble, and possibly the dimensions. Character id may not may not be useful, unless you use it to change the appearance of the text bubble or font.
For controlling background music, you can have an attribute specifying whether to play or to stop the currently playing music. The background music to play can also be specified as child node.
For sound effect, you can specify the track you want to play.
This is some ideas I thought up as I think what features the app can have. I can give more idea if you give a bit more details.
Side issue about display: Make sure the
pngfile has transparent outside edges, and set the UIImageView background color to[UIColor clearColor].