0

我正在开发俄罗斯方块类型的游戏。在正常情况下它运作良好。但是当我回击和租客时。砖不倒。这意味着 CCMoveTo 似乎不像工作。这是我的代码部分

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);

和我的 spriteMoveFinished 方法

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;

            }
        }
4

1 回答 1

0

也许你暂停游戏。

如果你有一个

[[CCDirector sharedDirector] 暂停]

你不能做任何动作。

尝试使用:

[[CCDirector sharedDirector]简历]

并在采取行动之后

于 2013-04-26T04:07:19.067 回答