Compiler errors 添加平移和缩放错误

Compiler errors 添加平移和缩放错误,compiler-errors,processing,Compiler Errors,Processing,我正在尝试将平移和缩放添加到我在processing.js中编写的应用程序中,下面是我的代码: 布尔surfaceTouchEvent(运动事件){ pointNum=event.getPointerCount(); 开关(event.getAction()&MotionEvent.ACTION\u掩码){ case MotionEvent.ACTION\u DOWN: //用户正在按手指 float x0=event.getX(0); float y0=event.getY(0); mode=

我正在尝试将平移和缩放添加到我在processing.js中编写的应用程序中,下面是我的代码:

布尔surfaceTouchEvent(运动事件){
pointNum=event.getPointerCount();
开关(event.getAction()&MotionEvent.ACTION\u掩码){
case MotionEvent.ACTION\u DOWN:
//用户正在按手指
float x0=event.getX(0);
float y0=event.getY(0);
mode=false;//拖动
打破
case MotionEvent.ACTION\u指针\u向下:
x1=event.getX(0);x2=event.getX(1);
y1=事件.getY(0);y2=事件.getY(1);
浮点数z4=距离(x1,y1,x2,y2);
mode=true;//收缩
打破
case MotionEvent.ACTION\u指针\u向上:
//用户松开其中一根手指。
打破
case MotionEvent.ACTION\u移动:
如果(模式=假){
x1=事件getX(0)-x0;
y1=事件getY(0)-y0;
}
如果(模式=真){
x1=event.getX(0);x2=event.getX(1);
y1=事件.getY(0);y2=事件.getY(1);
浮点数z3=距离(x1,y1,x2,y2);
如果(z3>z4){
缩放+=0.1;
}
else if(z3
我在case MotionEvent.ACTION\u POINTER\u DOWN中保存了较旧的位置用于缩放,在case MotionEvent.ACTION\u DOWN中保存了用于平移。我需要这个旧的位置来比较新的距离和旧的缩放距离

以下是错误:

compile:
    [javac] Compiling 2 source files to C:\DOCUME~1\T0P4568\LOCALS~1\Temp\android893850823480544580.pde\bin\classes
    [javac] C:\DOCUME~1\T0P4568\LOCALS~1\Temp\android893850823480544580.pde\src\changethispackage\beforesubmitting\tothemarket\sketch_may28a\sketch_may28a.java:118: variable x0 might not have been initialized
    [javac] x1=event.getX(0)-x0;
    [javac]                  ^
    [javac] C:\DOCUME~1\T0P4568\LOCALS~1\Temp\android893850823480544580.pde\src\changethispackage\beforesubmitting\tothemarket\sketch_may28a\sketch_may28a.java:119: variable y0 might not have been initialized
    [javac] y1=event.getY(0)-y0;
    [javac]                  ^
    [javac] C:\DOCUME~1\T0P4568\LOCALS~1\Temp\android893850823480544580.pde\src\changethispackage\beforesubmitting\tothemarket\sketch_may28a\sketch_may28a.java:125: variable z4 might not have been initialized
    [javac] if ( z3 > z4 ){
    [javac]           ^
    [javac] 3 errors

请帮忙

好的,您显然在使用processing.org,它将其代码编译为java

解决方案很简单:将
x0
y0
z4
预先初始化为默认值,例如
0

这只是为了安抚java编译器,因为它不够聪明,无法理解当它们被读取时,它们已经被初始化了