あなたに問題がなければ、OpenGLビューでそれをしなければならないでしょう、それは本当にとても簡単です。情報を表示するには、CCLabelクラスが必要です。位置を変更するには、CCMoveTo / CCMoveByアクションが必要です。不透明度を変更するには、CCFadeTo / CCFadeIn / CCFadeOutアクションが必要です。遅延を作成するには、CCDelayTimeが必要です。すべてを連携させるには、CCSpawnとCCSequenceが必要です。
CCSpawnは同時に複数のアクションを実行し(たとえば、フェードインして右から中央に移動)、CCSequenceは複数のアクションを1つずつ実行します(フェードイン+中央に移動、同時に遅延、フェードアウトするシーケンス) +中央から左に移動します)。次に、ラベルを作成してアクションを実行するメソッドのみをスケジュールする必要があります。コードでは、次のようになります
完全なアニメーション時間を定義しましょう
#define ANIMATION_TIME 4.f
アニメーションを開始したい場所でのスケジュール方法
[self schedule:@selector(runNextMessage) interval:ANIMATION_TIME];
runNextMessage
毎秒メソッドを呼び出しANIMATION_TIME
ます
- (void) runNextMesage
{
NSString* message = //get next message
CCLabelTTF* label = [CCLabelTTF labelWithString:message
dimensions:desiredDimensionsOfTheLabel
alignment:UITextAlignmentLeft
lineBreakMode:UILineBreakModeWordWrap
fontName:@"Arial"
fontSize:20.f];
CGSize winSize = [[CCDirector sharedDirector] winSize];
// place the label out the right border
[label setPosition: ccp(winSize.width + label.contentSize.width, winSize.height / 2)];
// adding it to the screen
[self addChild:label];
ccTime spawnTime = ANIMATION_TIME / 3;
// create actions to run
id appearSpawn = [CCAction actionOne:[CCMoveTo actionWithDuration:spawnTime]
two:[CCFadeIn actionWithDuration:spawnTime]];
// create show action and disappear action
// create result sequence
id sequence = [CCSequence actions: appearSpawn, showAction, disappearAction, nil];
[label runAction: sequence];
}