【发布时间】:2013-08-16 05:59:17
【问题描述】:
我正在画布上绘制一个缩放位图,并希望在指定时间淡出我的图像。
基本上,当我的角色图像越过画布的某个部分时,我需要角色图像慢慢消失(3 秒),然后页面会自动重定向到下一个 java 类。
目前,我的图像只是重定向到新的 java 类,请参阅下面的一些代码,了解我是如何创建图像的。
Resources res = getResources();
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 20, res.getDisplayMetrics());
imgSpacing = (int) px / 2;
int size = (int) ((PhoneWidth / 5) - px);
chrImg = BitmapFactory.decodeResource(getResources(), R.drawable.character);
chrImg = Bitmap.createScaledBitmap(chrImg, size, size, true);
然后在画布上onDraw:
if(indexX == mazeFinishX && indexY == mazeFinishY)
{
canvas.drawBitmap(finish, j * totalCellWidth, i * totalCellHeight, null);
// As soon as the character moves over this square they are automatically re-directed to new page
// This is where I want to fade the character image out before the re-direct
}
我在网上查看过,但无法完全弄清楚如何让褪色功能适用于从我的游戏资源可绘制文件夹中获取的可绘制图像。谢谢
【问题讨论】:
标签: android image bitmap android-canvas fadeout