F
Flo935
Neues Mitglied
- 0
Hallo,
ich bin mit meiner ersten kleinen App bald fertig, habe aber dennoch zwei Probleme.
1. Ich will hier (siehe Kommentare im Code) eine Endlosschleife erstellen, die Animation soll aber noch zu Ende laufen! Erst dann soll die Schleife wiederholt werden. Ich habe bis jetzt sehr viel probiert, es hat aber nicht funktioniert.
public void jump (View view) {
img = (ImageView) findViewById(R.id.imageViewball);
imgb = (ImageView) findViewById(R.id.imageViewblock);
startgamevalue++;
if (startgamevalue==0) {
//Endlosschleife - Beginn
imgb.animate().translationX(-3000).setDuration(2000).setListener(new Animator.AnimatorListener() {
@override
public void onAnimationStart(Animator animation) {
}
@override
public void onAnimationEnd(Animator animation) {
imgb.animate().translationX(0).setDuration(0);
}
@override
public void onAnimationCancel(Animator animation) {
}
@override
public void onAnimationRepeat(Animator animation) {
}
});
}
//Endlosschleife - Ende
img.animate().translationY(-250).setDuration(200).setListener(new Animator.AnimatorListener() {
@override
public void onAnimationStart(Animator animation) {
}
@override
public void onAnimationEnd(Animator animation) {
img.animate().translationY(0).setDuration(200);
}
@override
public void onAnimationCancel(Animator animation) {
}
@override
public void onAnimationRepeat(Animator animation) {
}
});
}
2. Ich brauche auch noch eine Methode/Schleife die prüft, ob die Koordinaten (x und y) von dem ImageView ball und dem ImageView block IRGENDWANN WÄHREND DER ANIMATION gleich sind. Ich weiß auch nicht wo ich diese Methode/Schleife dann platzieren soll, dass das alles funktioniert.
Danke im Vorraus!
ich bin mit meiner ersten kleinen App bald fertig, habe aber dennoch zwei Probleme.
1. Ich will hier (siehe Kommentare im Code) eine Endlosschleife erstellen, die Animation soll aber noch zu Ende laufen! Erst dann soll die Schleife wiederholt werden. Ich habe bis jetzt sehr viel probiert, es hat aber nicht funktioniert.
public void jump (View view) {
img = (ImageView) findViewById(R.id.imageViewball);
imgb = (ImageView) findViewById(R.id.imageViewblock);
startgamevalue++;
if (startgamevalue==0) {
//Endlosschleife - Beginn
imgb.animate().translationX(-3000).setDuration(2000).setListener(new Animator.AnimatorListener() {
@override
public void onAnimationStart(Animator animation) {
}
@override
public void onAnimationEnd(Animator animation) {
imgb.animate().translationX(0).setDuration(0);
}
@override
public void onAnimationCancel(Animator animation) {
}
@override
public void onAnimationRepeat(Animator animation) {
}
});
}
//Endlosschleife - Ende
img.animate().translationY(-250).setDuration(200).setListener(new Animator.AnimatorListener() {
@override
public void onAnimationStart(Animator animation) {
}
@override
public void onAnimationEnd(Animator animation) {
img.animate().translationY(0).setDuration(200);
}
@override
public void onAnimationCancel(Animator animation) {
}
@override
public void onAnimationRepeat(Animator animation) {
}
});
}
2. Ich brauche auch noch eine Methode/Schleife die prüft, ob die Koordinaten (x und y) von dem ImageView ball und dem ImageView block IRGENDWANN WÄHREND DER ANIMATION gleich sind. Ich weiß auch nicht wo ich diese Methode/Schleife dann platzieren soll, dass das alles funktioniert.
Danke im Vorraus!