清理cpp 内容, 只保留主文件。CMakeLists.txt 采用根目录的。
This commit is contained in:
@@ -1,14 +1,42 @@
|
||||
package com.hmwl.sample;
|
||||
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import com.google.androidgamesdk.GameActivity;
|
||||
|
||||
public class MainActivity extends GameActivity {
|
||||
public class MainActivity extends GameActivity{
|
||||
private static final String TAG = "MainActivity";
|
||||
|
||||
static {
|
||||
System.loadLibrary("sample");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
int action = event.getActionMasked();
|
||||
float x = event.getX();
|
||||
float y = event.getY();
|
||||
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
Log.d(TAG, "Java Layer: Touch DOWN at (" + x + ", " + y + ")");
|
||||
// ✅ 你可以在这里做些事,比如发消息给 C++,或 UI 反馈
|
||||
break;
|
||||
case MotionEvent.ACTION_MOVE:
|
||||
Log.d(TAG, "Java Layer: Touch MOVE");
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
Log.d(TAG, "Java Layer: Touch UP");
|
||||
break;
|
||||
}
|
||||
|
||||
// ⚠️ 关键:返回 false 才能让事件继续传递给 Native 层(C++)
|
||||
// 如果返回 true,表示事件已被消费,C++ 层将收不到!
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
|
||||
Reference in New Issue
Block a user