I am working on tetris type of game. In normal its working well. But when i press back and renters . bricks doesnt falls. That means CCMoveTo is not seems to be like working. here is my code part
CCMoveTo actionMove1 = CCMoveTo.action(actualDuration/divisor, CGPoint.ccp(randwidth , targetHeight));
CCCallFuncN actionMoveDone1 = CCCallFuncN.action(this, "spriteMoveFinished");
CCSequence actions1 = CCSequence.actions(actionMove1, actionMoveDone1);
target.runAction(actions1);
and my spriteMoveFinished method
public void spriteMoveFinished(Object sender)
{
target=(CCSprite) sender;
if(targetHeight<=(newtarget+target.getContentSize().height/2))
{
CCMoveTo actionMove = CCMoveTo.action(0 , CGPoint.ccp(randwidth ,(newtarget+target.getContentSize().height/2)));
CCCallFuncN actionMoveDone = CCCallFuncN.action(this, "spriteMoveFinishedy");
CCSequence actions = CCSequence.actions(actionMove, actionMoveDone);
target.runAction(actions);
arraycounter++;
int n= Height/brick;
targetHeight=n*brick;
if(xpos!=position)
{
CCBlink u=CCBlink.action(3f, 3);
CCCallFuncN actionMoveDone1 = CCCallFuncN.action(this, "spriteMoveFinishedx");
CCSequence actions1 = CCSequence.actions(u, actionMoveDone1);
target.runAction(actions1);
}
else
{
updateHeight(shape,position);
gameLogic();
}
}
else
{
// for continuation motion of CCSprite
if(tag==0)
{
targetHeight=targetHeight-brick;
newtarget=positioning(shape,position);
if(targetHeight<newtarget+target.getContentSize().height/2)
{
targetHeight=(int) ( newtarget+target.getContentSize().height/2);
}
CCMoveTo actionMove = CCMoveTo.action(actualDuration/divisor, CGPoint.ccp(randwidth ,targetHeight));
CCCallFuncN actionMoveDone = CCCallFuncN.action(this, "spriteMoveFinished");
CCSequence actions = CCSequence.actions(actionMove, actionMoveDone);
target.runAction(actions);
tag=1;
}
// to stuck the CCSprite movement
else
{
CCMoveTo actionMove = CCMoveTo.action(actualDuration/latedivisor , CGPoint.ccp(randwidth ,targetHeight));
CCCallFuncN actionMoveDone = CCCallFuncN.action(this, "spriteMoveFinished");
CCSequence actions = CCSequence.actions(actionMove, actionMoveDone);
target.runAction(actions);
tag=0;
}
}
maybe you pause the game.
if you have a
[[CCDirector sharedDirector] pause]
you can't do any action.
try using:
[[CCDirector sharedDirector] resume]
and after make the action