onTrackballEvent

Put your problem here if it does not fit any of the other categories.

onTrackballEvent

Postby MickArea » Sun Mar 22, 2009 6:33 am

Hi guys,

i have few question for you.


i try to make a game, but i didn't pay attention until now about the gameplay :p

I used the arrow keys, but the version of G2 use the trackball, right ?

so what is the best way to use the trackball ? i didn't find any tutorial about that.

I used this code ;

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.                 switch (event.getAction()) {
  3.  
  4.                 case MotionEvent.ACTION_DOWN:
  5.  
  6.                         break;
  7.  
  8.                 case MotionEvent.ACTION_UP:
  9.  
  10.                         return true;
  11.  
  12.                 case MotionEvent.ACTION_CANCEL:
  13.  
  14.                         return true;
  15.  
  16.                 case MotionEvent.ACTION_MOVE:
  17.  
  18.                         //
  19.  
  20.                         float x = event.getX() * event.getXPrecision();
  21.  
  22.                         float y = event.getY() * event.getYPrecision();
  23.  
  24.                         if(Math.abs(x)>Math.abs(y)) {
  25.  
  26.                                 if(x>0){
  27.  
  28.                                    // right
  29.  
  30.                                }else{
  31.  
  32.                                   // left
  33.  
  34.                                }
  35.  
  36.                         }else if(Math.abs(x)<Math.abs(y)) {
  37.  
  38.                                if(y>0){
  39.  
  40.                                    // down
  41.  
  42.                                }else{
  43.  
  44.                                   // up
  45.  
  46.                                }
  47.  
  48.                         }
  49.  
  50.  
  51.  
  52.                 }
  53.  
  54.                 return super.onTrackballEvent(event);
  55.  
  56.         }
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


any other idea ?


and why using trackball make the application slowly :(
MickArea
Junior Developer
Junior Developer
 
Posts: 23
Joined: Mon Feb 23, 2009 4:42 pm

Top

Re: onTrackballEvent

Postby sarangkulkarni17 » Mon Mar 23, 2009 5:55 am

I am also developing game that uses TrackballEvent.
For moving my object on screen i used onKeyDown() i have to press key until my object is in safe place.
i wrote in onKeyDown()

xPosition+=5;

& i want my object to move until i releases the key......

but it is not working :(

can anybody help???
sarangkulkarni17
Developer
Developer
 
Posts: 29
Joined: Fri Feb 13, 2009 10:00 am
Location: Pune

Re: onTrackballEvent

Postby sarangkulkarni17 » Thu Mar 26, 2009 7:05 am

can anybody help???
sarangkulkarni17
Developer
Developer
 
Posts: 29
Joined: Fri Feb 13, 2009 10:00 am
Location: Pune

Re: onTrackballEvent

Postby saamyandroid » Sat Nov 28, 2009 6:04 am

facing same problem.

guys plz help us
Thanks in advance
Saamy
saamyandroid
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Wed Sep 09, 2009 8:17 pm
Location: INDIA

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 10 guests