CC MoveTo无法在Cocos2d android中运行

时间:2013-04-24 16:44:20

标签: android cocos2d-android

我正在研究俄罗斯方块类型的游戏。在正常情况下它运作良好。但是当我按下并租房时。砖不会下降。这意味着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;

            }
        }

1 个答案:

答案 0 :(得分:0)

也许你暂停游戏。

如果你有

  

[[CCDirector sharedDirector] pause]

你不能做任何动作。

尝试使用:

  

[[CCDirector sharedDirector] resume]

并且在做出行动之后