本文介绍了Android的帆布规模,翻译和并主张的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用帆布规模放大之后,在移动限制,但新坐标不匹配。结果
我宽度480,1.5F后缩放我的宽度为720 ...但是当我设置转化为-480,我看到右边更大的空间。

I'm trying the moving limit after zoom with canvas scale, but new coordinates does not match.
my width 480, after 1.5f zooming my width will be 720... but when I set translate to -480, I'm seeing more space on the right.

float zoom = 0.5f;
PointF translate = new PointF(0, 0);
canvas.scale(zoom, zoom);
canvas.translate(translate.x, translate.y);
//...
canvas.drawRect(0, 0, width, height, paint);

对不起我的英语不好和解释,但我想问问在总结;结果
什么是真正的宽/高限缩放移动画布后翻译?

sorry my bad English and explanation, but I want to ask in summary;
what is the true width/height limit for translate after zooming for moving the canvas?

推荐答案

我解决了这个问题如下:

I solved this problem as follows;

(屏幕分辨率:800×480 [横向])

(screen resolution: 800x480 [landscape])

int screenWidth = 800;
int gameLimitX = 1600;
int cameraPositionX = 0;

float zoom = 1.0;

if((screenWidth / zoom) + cameraPositionX > gameLimitX) {
    cameraPositionX = (screenWidth / zoom) + cameraPositionX;
}

(对于Y /身高做同样的)结果
我希望你能理解。

(do same for y/height)
I hope you can understand.

这篇关于Android的帆布规模,翻译和并主张的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 04:49