- if ( mFirstTransition && (!mIsToNextImage) ) // for the first transition and it is going to previous image
- {
- mTiles[mContainerIndex][actorIndex].SetRotation( Radian( angle), axis );
- }
- else if( !mChangeTurningDirection ) // reset rotation, translation and color
- {
- mTiles[mContainerIndex][actorIndex].MoveBy( resetTranslation );
- mTiles[mContainerIndex][actorIndex].SetRotation( Radian( angle), axis );
- }
- mAnimation.RotateTo( mBoxes[actorIndex], Radian( -angle ), axis, AlphaFunctions::EaseInOutSine );
- Vector3 position(mBoxes[actorIndex].GetCurrentPosition());
- mAnimation.MoveTo(mBoxes[actorIndex], position*mDisplacementRatio+Vector3(0.f,0.f,mCubeDisplacement), AlphaFunctions::Bounce);
- mAnimation.ColorTo( mTiles[mContainerIndex^1][actorIndex], HALF_BRIGHTNESS, AlphaFunctions::EaseOut );
- mAnimation.ColorTo( mTiles[mContainerIndex][actorIndex], FULL_BRIGHTNESS, AlphaFunctions::EaseIn );
+ const Vector2 size = Self().GetCurrentProperty< Vector3 >( Actor::Property::SIZE ).GetVectorXY();
+ Vector2 halfSize = size * 0.5f;
+
+ //the position of the centre of the front face tile
+ Vector3 position( halfSize.x * (2.0f * x + 1.0f) / mColumns, halfSize.y * (2.0f * y + 1.0f ) / mRows, 0.0f );
+
+ Vector3 direction = position - displacementCentre;
+ float length = direction.Length();
+ direction.Normalize();
+
+ float deltaLength = mCubeDisplacement / direction.z; //the length along the direction vector such that the projected direction onto the z axis is equal to mCubeDisplacement
+
+ Vector3 newPosition = ( direction * (length + deltaLength ) ) + displacementCentre;
+ Vector3 newLocalPosition = newPosition - position;
+
+ mAnimation.AnimateTo( Property( mBoxes[ actorIndex ], Actor::Property::ORIENTATION ), Quaternion( Radian( -angle ), axis ), AlphaFunction::EASE_IN_OUT_SINE );
+ mAnimation.AnimateTo( Property( mBoxes[ actorIndex ], Actor::Property::POSITION ), newLocalPosition, AlphaFunction::BOUNCE );
+
+ mAnimation.AnimateTo( Property( mCurrentTiles[ actorIndex ], Actor::Property::COLOR ), HALF_BRIGHTNESS, AlphaFunction::EASE_OUT );
+ mAnimation.AnimateTo( Property( mTargetTiles[ actorIndex ], Actor::Property::COLOR ), FULL_BRIGHTNESS, AlphaFunction::EASE_IN );