I am drawing a scaled bitmap onto a canvas and would like to fade my image out at a specified time.
Basically, when my character image goes over a certain section of the
if(indexX == mazeFinishX && indexY == mazeFinishY)
{
canvas.drawBitmap(finish, j * totalCellWidth, i * totalCellHeight, null);
// As soon as the character moves over this square they are automtically re-directs to new page
new CountDownTimer(0500, 1000) {
@Override
public void onTick(long millisUntilFinished) {}
@Override
public void onFinish() {
Paint paint = new Paint();
paint.setAlpha(25);
canvas.drawBitmap(chrImg, 0, 0, paint);
}
}.start();
new CountDownTimer(0500, 1000) {
@Override
public void onTick(long millisUntilFinished) {}
@Override
public void onFinish() {
Paint paint = new Paint();
paint.setAlpha(45);
canvas.drawBitmap(chrImg, 0, 0, paint); }
}.start();
new CountDownTimer(0500, 1000) {
@Override
public void onTick(long millisUntilFinished) {}
@Override
public void onFinish() {
Paint paint = new Paint();
paint.setAlpha(70);
canvas.drawBitmap(chrImg, 0, 0, paint); }
}.start();
new CountDownTimer(0500, 1000) {
@Override
public void onTick(long millisUntilFinished) {}
@Override
public void onFinish() {
Paint paint = new Paint();
paint.setAlpha(100);
canvas.drawBitmap(chrImg, 0, 0, paint); }
}.start();
// This is where I want to fade the character image out before the re-direct
new CountDownTimer(3000, 1000) {
@Override
public void onTick(long millisUntilFinished) {
// TODO Auto-generated method stub
}
@Override
public void onFinish() {
// TODO Auto-generated method stub
Intent i = new Intent(currentclass.this, nextClass.class);
startActivity(i);
}
}.start();
}
this will make your bitmap becomes transparent ( the alpha will be 100 ) .. and then redirect to the next class after 3 seconds.
Update: for the bitmap you can't use .setAlpha so we must use a paint, so we created a new paint each time then set the bitmap with the paint. but if you have an imageView you can use .setalpha