Typing action for CCLabelTTF?

Forums Programming cocos2d support (graphics engine) Typing action for CCLabelTTF?

This topic contains 1 reply, has 1 voice, and was last updated by  dgtheman 2 years, 2 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
Author Posts
Author Posts
January 30, 2012 at 1:05 am #238811

dgtheman
Participant
@dgtheman

Is there an action that types out a CCLabel or something of that sort? I cant use CCFadeIn because it doesnt essentially “type” the words. What I mean by this is having an action which takes the individual letters from the string in the label and makes them appear as if they are being typed. Ex:

http://www.youtube.com/watch?v=rCpbc23APqg&feature=related

^Thats pretty much what i want to do with a CCLabel

January 30, 2012 at 3:00 am #363856

dgtheman
Participant
@dgtheman

Ok so I got it…just in case anyone is wondering…there is no actual action for this.

Here is a rough ex:

//Interface
CCLabelTTF *label;
NSString *stringForLabel;
int currentIndex;
//Init
label = [CCLabelTTF labelWithString:@"" ....];
stringForLabel = @"Whatever string you want";
currentIndex = 0;
[self schedule:@selector(updateLabel:) interval:0.05f];
//beneath init
-(void)updateLabel:(ccTime)delta
{
if(currentIndex < [stringForLabel length])
{
[label setString:[NSString stringWithFormat:@"%@%c",[label string], [stringForLabel characterAtIndex:currentIndex];
currentIndex++;
}
else
[self unschedule:@selector(updateLabel:)];
}

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.