开发者

How to implement multi-touch in an android game that uses a main game panel surface view and a main thread

开发者 https://www.devze.com 2023-01-31 03:42 出处:网络
I started learning android programming a couple of weeks ago. I am a beginner so I followed this tutorial on making a simple 2D game engine:

I started learning android programming a couple of weeks ago. I am a beginner so I followed this tutorial on making a simple 2D game engine:

http://obviam.net/index.php/a-very-basic-the-game-loop-for-android/

I implemented the onTouchEvent(MotionEvent event) method in the main game panel surface view. Everything seemed to work until I ran the game on an actual device (Galaxy Vibrant 2.1-update). I then noticed the game doesn't respond to ACTION_POINTER_DOWN开发者_Python百科 or ACTION_POINTER_UP events. Does anyone know how to implement multitouch in a game engine of this structure? I am completely stuck and have tried everything. I even tried implementing Robert Green's DIY multitouch test app within my main game panel surface view, but still my app didnt respond to pointer actions, only MOVE_DOWN and MOVE_UP actions

source code to multitouch test app: http://*.rbgrn.net/content/367-source-code-to-multitouch-visible-test (replace * with www) Should i be listening to touch events on the main game panel class like the tutorial says?


I found out using if and else statements in the onTouchEvent method is kind of buggy. I changed those statements to a switch case instead and it now works.


I found this example is useful and easy for multitouch

http://android-coding.blogspot.com/2011/05/detect-multi-touch-on-surfaceview.html

0

精彩评论

暂无评论...
验证码 换一张
取 消