0

次のコードを見てみましょう。

    CCTintTo *tint1 = [CCTintTo actionWithDuration:4 red:255 green:0 blue:0];
    CCTintTo *tint2 = [CCTintTo actionWithDuration:4 red:0 green:0 blue:255];
    CCTintTo *tint3 = [CCTintTo actionWithDuration:4 red:0 green:255 blue:0];
    CCSequence *sequence = [CCSequence actions:tint1, tint2, tint3, nil];
    CCRepeatForever *repeat = [CCRepeatForever actionWithAction:sequence];
    CCSpeed *speedAction = [CCSpeed actionWithAction:repeat speed:10];

ご覧のとおり、最初の3つのアクションは、4秒でそれぞれ赤、青、緑に色を付けるアクションです。次に、これらのアクションのシーケンスが10の速度でCCSpeedアクションに渡されます。今、私がまったく理解できないのは、これらの期間がどのように機能するかです。つまり、最初の3つは4秒で完了するはずですが、速度の方法は高速で、それほど長持ちしません。このような場合の行動の期間に関して私が知っておくべき原則は何ですか?

4

1 に答える 1

0

私の知る限り、CCSpeedアクションはその中のCCActionInterval全体を変更するだけです。つまり、シーケンスの継続時間が 12 秒の場合、このシーケンスを速度 10 の CCSpeed アクションに渡すことによって、このシーケンスの継続時間が 12 秒から 120 秒に増加します。

もう 1 つのポイントは、CCSpeed アクションがメソッド内の CCActionInterval サブクラスを待機するactionWithAction:speed:ことです。そのため、CCRepeatForever アクションを渡すことはできません。このアクションを永遠に繰り返したい場合は、次のように呼び出しを行う必要があります

CCSequence *sequence = [CCSequence actions:tint1, tint2, tint3, nil];
CCSpeed* speedAction = [CCSpeed actionWithAction:sequence speed:10];
CCRepeatForever* repeat = [CCRepeatForever actionWithAction:speedAction];
于 2012-06-19T21:23:46.763 に答える