本文介绍了Android onTouchEvent错误,“;"预期的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

我现在正在尝试精通用于移动游戏的OpenGL,因此我需要问一些有关此问题的问题.这是我目前的问题.

规格:
-android SDK API 6(android 2.1)
-使用命令行创建新项目,构建和安装
-使用模拟器(AVD)运行程序
-Windows 7 Pro SP 1 32x

我正在尝试在触摸(onTouchEvent)的android中旋转三角形.
这是我的代码段:

Hi there,

I''m now trying to mastering OpenGL for mobile gaming, so I''ll need to ask a boxes of question about it. Here''s my current problem now.

Specification :
- android SDK API 6 (android 2.1)
- using command line to create new project, build, and install
- using emulator (AVD) to run program
- Windows 7 Pro SP 1 32x

I''m trying to rotate triangle in my android on touch (onTouchEvent).
Here''s my code snippet :

package .....;
import android.app.Activity;
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

public class segitiga extends Activity{
..
..
..
..
}

class HelloOpenGLES10SurfaceView extends GLSurfaceView {
...
...
...
public HelloOpenGLES10SurfaceView(Context context){
...
...
@Override
    public boolean onTouchEvent(MotionEvent e) {

        float x = e.getX();
        float y = e.getY();

        switch (e.getAction()) {
            case MotionEvent.ACTION_MOVE:

                float dx = x - mPreviousX;
                float dy = y - mPreviousY;

                // reverse direction of rotation above the mid-line
                if (y > getHeight() / 2) {
                  dx = dx * -1 ;
                }

                // reverse direction of rotation to left of the mid-line
                if (x < getWidth() / 2) {
                  dy = dy * -1 ;
                }

                mRenderer.mAngle += (dx + dy) * TOUCH_SCALE_FACTOR;
                requestRender();
        }

        mPreviousX = x;
        mPreviousY = y;
        return true;
    }

}
}



问题是当我尝试编译(安装debug/adb installd)到我的模拟器时,它在:
的行上向我抛出了这样的错误



The porblem is when I tried to compile (install debug / adb installd ) to my emulator it''s throw me error like this on the line of :

public boolean onTouchEvent(MotionEvent e)



它需要;"在onTouchEvent之后和"e"之后.所以应该像这样根据编译器:



It need ";" after onTouchEvent and after "e". So it should be this like according to the compiler :

public boolean onTouchEvent;(MotionEvent e;)



那是错误的事情.
我该如何解决?

在此先感谢



And that''s wrong things.
How should I fixe it?

Thanks in advances

推荐答案


这篇关于Android onTouchEvent错误,“;"预期的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 21:19