我想将黑暗和令人沮丧的背景实时更改为快乐的草皮背景,以使快乐背景以游戏角色周围的半径显示。
如果愿意的话,幸福的力量场。
在自定义视图中渲染到画布时,如何尽可能高效地完成此操作?
更新: 这就是我的脑海:
private int hModeX, hModeY;
private float hModeRadius = 0.1f;
private float hModeStart = 0;
happyModeBg = Bitmap.createScaledBitmap(happyModeBg, getWidth(),getHeight(), true);
hModeX = getWidth()/2;
hModeY = getHeight()/2;
private void initHappyMode(Canvas canvas){
hModeRadius = 75 * thread.getDelta();
if(hModeRadius > 500) {
hModeStart = timestep; //What is timestep?
}
//context.arc(x, y, radius, 0, 2 * Math.PI, false); <- your version
canvas.save();
canvas.drawArc(oval, startAngle, sweepAngle, useCenter, paint) // <- my version
//context.clip(); <- dont know what this does or if there is an equivilant
canvas.drawBitmap(happyModeBg, 0, 0, null);
canvas.restore();
//requestAnimationFrame(step); <- dont know what this does since I cant seem to find it for android
}
我过去canvas.drawArc()
经常做个圆圈,但我肯定缺少某些东西。
Canvas
功能与HTML略有不同<canvas>
,我以为您的意思是HTML !我已经编辑了答案,通过一些特定于Android的链接和示例代码来说明剪辑的总体工作原理。