I am making a simple learning app for my school kids. I don't know coding but I used a tutorial to make this app. Which will pick random fruits(images) from drawable and make them fall down the screen(Y-position += 5).
I have declared them on onCreate
apple = (ImageView) findViewById(R.id.apple);
banana = (ImageView) findViewById(R.id.banana);
grapes = (ImageView) findViewById(R.id.grapes);
after that
public void changePosition(){
appleY += 5;
if(appleY > screenHeight ) {
appleX = (int) Math.floor(Math.random() * (frameWidth - apple.getWidth()));
appleY = screenHeight - (screenHeight + 50);
}
apple.setX(appleX);
apple.setY(appleY);
bananaY += 5;
if (bananaY > screenHeight) {
bananaX = (int) Math.floor(Math.random() * (frameWidth - banana.getWidth()));
bananaY = screenHeight - (screenHeight + 50);
}
banana.setX(bananaX);
banana.setY(bananaY);
}
this makes them fall together, which might be confusing for small kids. I want it to let one image cross the screen then other should come but randomly, like apple - banana - apple - grapes - mango - banana.
please guide me. Thank you
Aucun commentaire:
Enregistrer un commentaire