mardi 27 septembre 2016

Pause a movement by accelerometer with ActionScript 3

So basically, I have a Tetris game code that make a movement by accelerometer, but the thing is, it couldn't stop moving until i get back to original position which is not okay.

Here is the code:

private function MTetromino(evt:Event)
    {
        if (! gameOver)
        {
            /*====== MOVE X =======*/
            if (accX > 0.3 && canFit(tRow,tCol - 1,currentRotation))
            {
                tCol--;
                placeTetromino();

            }
            else if (accX < -0.3 && canFit(tRow,tCol + 1,currentRotation))
            {
                tCol++;
                placeTetromino();
            }

            /*====== MOVE Y =======*/
            if (accY < -0.15 && canFit(tRow,tCol,rot))
            {
                var ct:uint = currentRotation;
                var rot:uint = (ct + 1) % tetrominoes[currentTetromino].length;
                currentRotation = rot;
                removeChild(tetromino);
                drawTetromino();
                placeTetromino();

            }
            else if (accY > 0.15 && canFit(tRow + 1,tCol,currentRotation))
            {
                tRow++;
                placeTetromino();

            }
        }
    }

I need a pause code or can make the tetromino move one time every tilt position. Please help, and thank you in advance for your answers.

Aucun commentaire:

Enregistrer un commentaire