-(void) gameplay
{
if (actionhappen){
CCActionSequence *mySeq = [CCActionSequence actionWithArray:@[do,some,action]];
[mySprite runAction:mySeq]; // it takes 3 seconds.
}
[self checkWinner];
}
-(void)checkWinner{
if (someoneWin){
// I want to wait here until mySeq action finished
[self showWinnerMessage];
}
}
このコードでは
[self showWinnerMessage]は、mySeqが終了する前に実行されます。
mySpriteアクションが終了するまでどのように待つことができますか?
Sleep()はすべてをスリープ状態にするようです。
さて、@ LearnCocos2Dはすでにコメントでこの質問に答えていますが、これを行うためのコードは次のとおりです。
-(void) gameplay
{
if (actionhappen)
{
CCActionCallFunc *checkWinner =
[CCActionCallFunc actionWithTarget:self selector:@selector(checkWinner)];
CCActionSequence *mySeq =
[CCActionSequence actionWithArray:@[do,some,action, checkWinner]]; //note checkWinner
[mySprite runAction:mySeq]; // it takes 3 seconds.
}
else
{
// in this case call the func directly
[self checkWinner];
}
}
-(void)checkWinner
{
if (someoneWin)
{
// I want to wait here until mySeq action finished
[self showWinnerMessage];
}
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加