Permalink
Browse files

テキストの表示速度倍速に

  • Loading branch information...
1 parent 2b8eea7 commit fe3c155890e794fc67cd178a513469a10a4dd45b @giginet committed Apr 3, 2012
Showing with 9 additions and 2 deletions.
  1. +1 −0 Heqet/sprite/KWMessageWindow.h
  2. +7 −2 Heqet/sprite/KWMessageWindow.m
  3. +1 −0 Projectfiles/MessageWindow.m
View
1 Heqet/sprite/KWMessageWindow.h
@@ -33,6 +33,7 @@
@property(readwrite) int currentMessageIndex;
@property(readwrite) int currentTextIndex;
+@property(readwrite) int updateTextLength;
@property(readwrite) double messageSpeed;
@property(readwrite) double autoSkipDelay;
@property(readwrite, strong) NSMutableArray* messages;
View
9 Heqet/sprite/KWMessageWindow.m
@@ -18,6 +18,7 @@ - (void)onNextMessage:(id)timer;
@implementation KWMessageWindow
@synthesize currentMessageIndex = currentMessageIndex_;
@synthesize currentTextIndex = currentTextIndex_;
+@synthesize updateTextLength;
@synthesize messageSpeed = messageSpeed_;
@synthesize autoSkipDelay;
@dynamic currentMessage;
@@ -32,6 +33,7 @@ - (id)init {
self.currentMessageIndex = 0;
self.messageSpeed = 1.0 / [[KKStartupConfig config] maxFrameRate];
self.autoSkipDelay = 0;
+ self.updateTextLength = 1;
messages_ = [NSMutableArray array];
timer_ = [KWTimer timerWithMax:self.messageSpeed];
timer_.looping = YES;
@@ -148,9 +150,12 @@ - (void)update:(ccTime)dt {
- (void)updateMessage {
if ([self isEndMessage]) return;
- ++self.currentTextIndex;
- //NSString* text = [self.currentMessage substringWithRange:NSMakeRange(self.currentTextIndex, 1)];
NSString* text = @"";
+ if (self.currentTextIndex + self.updateTextLength < (int)[self.currentWholeMessage length]) {
+ self.currentTextIndex += self.updateTextLength;
+ } else {
+ self.currentTextIndex = self.currentWholeMessageLength - 1;
+ }
[self.delegate didUpdateText:self text:text];
if ([self isEndMessage]) {
[self onCompleteMessage];
View
1 Projectfiles/MessageWindow.m
@@ -31,6 +31,7 @@ - (id)initWithMessages:(NSArray *)messages alignment:(UITextAlignment)alignment
if (self) {
self.delegate = self;
self.autoSkipDelay = 0.5;
+ self.updateTextLength = 2;
shadowLabel_ = [CCLabelTTF labelWithString:self.messageLabel.string
dimensions:self.messageLabel.contentSize
alignment:alignment

0 comments on commit fe3c155

Please sign in to comment.