private void action(int action) { mCubicStartAniSprite.setVisible(false); mCubicStartAniSprite.stopAnimation(0); switch (action) { case ACTION_TURN_LEVEL_1: case ACTION_TURN_LEVEL_2: case ACTION_TURN_LEVEL_3: ACTION = action; final Body body = (Body) this.getUserData(); final Vector2 vector2 = Vector2Pool.obtain(body.getPosition()); int frame[] = new int[] {0, 1}; body.setAngularDamping(1.2f); vector2.x = vector2.x / 3; vector2.y = vector2.y / 3; if (action == ACTION_TURN_LEVEL_2) { frame = new int[] {2, 3}; body.setAngularDamping(2.2f); vector2.x = vector2.x / 2; vector2.y = vector2.y / 2; } else if (action == ACTION_TURN_LEVEL_3) { frame = new int[] {4, 5}; body.setAngularDamping(3.2f); } Vol3Osyougatsu.OGG_A3_A_5_KOMATEI.play(); mCubicTurnAniSprite.animate(new long[] {250, 250}, frame, -1); mCubicTurnAniSprite.setVisible(true); body.setActive(true); Log.i(TAG, "body.getPosition " + vector2); vector2.x = random(vector2.x) + new Random().nextFloat(); vector2.y = random(vector2.y) + new Random().nextFloat(); body.setLinearVelocity(vector2); Log.i(TAG, "body.getPosition change " + vector2); this.unregisterUpdateHandler(timerHandler); this.registerUpdateHandler( timerHandler = new TimerHandler( 6f, new ITimerCallback() { @Override public void onTimePassed(TimerHandler timerHandler) { // Stop Turn stopTurn(); } })); break; } }
// Function Stop Turn when out time and collision "shishi" public void stopTurn() { Vol3Osyougatsu.OGG_A3_A_5_KOMATEI.stop(); ACTION = ACTION_TURN_STOP; for (int i = 0; i < mCubicTurnOptionAniSprite.length; i++) { mCubicTurnOptionAniSprite[i].stopAnimation(); mCubicTurnOptionAniSprite[i].setVisible(false); } mCubicTurnAniSprite.stopAnimation(0); mCubicTurnAniSprite.setVisible(false); removePhysics(CubicEntity.this); mCubicStopAniSprite.animate( new long[] {200, 1000}, new int[] {0, 1}, 0, new IAnimationListener() { @Override public void onAnimationStarted(AnimatedSprite arg0, int arg1) { mCubicStopAniSprite.setVisible(true); } @Override public void onAnimationLoopFinished(AnimatedSprite arg0, int arg1, int arg2) {} @Override public void onAnimationFrameChanged(AnimatedSprite arg0, int arg1, int arg2) { Log.i("XXX", arg1 + " Changed ID : " + arg2); int index = arg2; if (index == -1) { index = 0; } if (index >= 2) return; float width = mCubicStopAniSprite.getTiledTextureRegion().getWidth(index); float height = mCubicStopAniSprite.getTiledTextureRegion().getHeight(index); Log.i("XXX", width + " ~ " + height); mCubicStopAniSprite.setWidth(width); mCubicStopAniSprite.setHeight(height); } @Override public void onAnimationFinished(AnimatedSprite arg0) { CubicEntity.this.clearAll(); mCubicChooseSpite[CubicEntity.this.TYPE].setVisible(true); CUBIC_SLOT[SLOT] = false; checkArrow(); } }); }