I am trying to make a game with several "screens." If the user moves to the edge of the screen, an animation should appear that shifts the current screen and switches to a new screen.
I wanted to do this with TranslateAnimation. First, I compute a bitmap that contains the first and second screens, and then I want to play it in the transitionView, while I hide the levelView that originally contained the first screen. When the transition is complete, I want to hide the "transitionView" again and display the new screen in the "levelView".
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/viewGroup"
android:layout_width="match_parent"
android:layout_height="match_parent">
<view
class="at.test.game.ScreenTransitionTest2$LevelView"
android:id="@+id/levelView"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<view
class="at.test.game.ScreenTransitionTest2$TransitionView"
android:id="@+id/transitionView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>
</RelativeLayout>
ImageView, , . View, (0, 0).
, onCreate:
((RelativeLayout)findViewById(R.id.viewGroup)).setClipChildren(false);
:
this.transitionView.setBitmap(calculateBitmap(screen1, screen2));
TranslateAnimation a = new TranslateAnimation(
Animation.ABSOLUTE, startx, Animation.ABSOLUTE, endx,
Animation.ABSOLUTE, starty, Animation.ABSOLUTE, endy);
a.setDuration(3000);
a.setFillAfter(true);
this.transitionView.setAnimation(a);
a.start();
: 480x800 / ( 1000x880, (-40, -40), endcoordinates (-520, -40)) ( , ) (. )
? ? 'wrap_content' view, . ?
- ,