I am doing a game like chess. As soon my player move is completed(if he starts move from one place to another), my AI move is started (before my player reaching his destination ). Sometimes i find difficult which AI coin is moved now. how to delay it.
A:
If your player movement is bounded by Core Animation, you can setup the setAnimationDidStopSelector
to a custom STOP function and starts your AI there.
If you have a game loop with states, just add enough states (e.g. user_move_began
, user_move_ended
, ai_think_began
, ai_think_ended
, ai_move_began
.. ) to sequence the flow.
ohho
2010-04-30 07:30:56
A:
I think I understand what you are saying now.
You need to do a CCSequence, with your AI function call in a CCCallFunc at the end:
CCSequence *playerMove = [CCSequence actions:
[CCMoveTo actionWithDuration: 0.4f position: CGPointMake(10,10)],
[CCCallFunc actionWithTarget: self selector: @selector(doAIstuff)],
nil];
[playerSprite runAction: playerMove];
You need to have your AI be a callable function (i.e. doAIstuff
). It is confusing to that you say the code is in draw().
Jeff B
2010-05-05 20:12:13