开发者

How to animate text to appear word by word for iphone app?

I want to do up a tuto开发者_运维技巧rial page with the main character giving speech bubbles. Suppose, I use UILabel/UITextView to contain those speeches, how do I animate the text to appear word by word like what we see in a rpg tutorial scene?

Thank you.


Go through the text you're planning, and partition it into an array, such that each element of the array would be a block of text you want your character to say.

(For example, element 0 might be @"Hey there, welcome to the tutorial!", element 1 might be @"The goal of this game is..." and so on.)

Then, I'd recommend using a UIButton to cycle through the text, so that your character will continue "speaking" when the user touches the screen.

To do this, simply create a button in Interface builder/Xcode, enlarge it to include the whole screen, and set the display mode to custom, making it invisible.

You may want to send it to back (The command is under Layout) so you can interact with the rest of your nib file though.

Link the button to an IBAction function along the lines of the following:

-(IBAction) continueTutorial{
    i ++; //Here i is an NSInteger from your .h file, set it to 0 when the tutorial starts
    YourUILabel.text = [yourArray objectAtIndex: i];
}

Hope this helps!


Go through the text by hand and mark each word or phrase by position (nth character, etc.) and the time you want it to appear relative to the last. Then use an NSTimer. Each time the timer goes off, put a larger and larger substring (to the nth-1 character) from your text into your textview's contents. Then (re)set the timer for the next word or phrase.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜