Low level spinner for games (test and input needed).

Quickly share your Android Code Snippets here...

Low level spinner for games (test and input needed).

Postby Jompe71 » Sun Jan 11, 2009 2:54 pm

Just in progress of making my new game and wanted to have a low level spinner (drop down in my own words) implementation.
I hacked one up quickly but need help in testing it. Please if you also need such an implementation try it out in your own app and give feedback on potential improvements. Some basic methods are missing such as removing, sorting items etc but the main part is there.

Note that the purpose of it is for games and it shall not have every feature a high level spinner has, just the basics to be used for ex. settings, in game options etc.

Usage:
in View onCreate() (note Image passed has internally hardcoded size set to 16x16px.)
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.        
  2.  
  3. lldd = new LowLevelDropDown( 20, 20, 150, 18, <Your_16x16_Bitmap> );
  4.  
  5. lldd.addItem( "Jompe71" );
  6.  
  7. lldd.addItem( "LowLevel" );
  8.  
  9. lldd.addItem( "DropDown" );
  10.  
  11. lldd.addItem( "Can be used" );
  12.  
  13. lldd.addItem( "In games !" );
  14.  
  15. lldd.addItem( "Please feel" );
  16.  
  17. lldd.addItem( "Free to try" );
  18.  
  19. lldd.addItem( "It out..." );
  20.  
  21.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


More View code
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.    
  2.  
  3.     @Override
  4.  
  5.     public boolean onTouchEvent( MotionEvent event ) {    
  6.  
  7.         lldd.update( ( int )event.getX(), ( int )event.getY(), event.getAction() );
  8.  
  9.         return true;
  10.  
  11.     }
  12.  
  13.  
  14.  
  15.     @Override
  16.  
  17.     public boolean onKeyUp( int code, KeyEvent event ) {
  18.  
  19.         switch( code ) {
  20.  
  21.             case KeyEvent.KEYCODE_DPAD_DOWN:
  22.  
  23.                 lldd.scrollDown();
  24.  
  25.                 return true;
  26.  
  27.  
  28.  
  29.             case KeyEvent.KEYCODE_DPAD_UP:
  30.  
  31.                 lldd.scrollUp();
  32.  
  33.                 return true;
  34.  
  35.         }
  36.  
  37.         return false;
  38.  
  39.     }
  40.  
  41.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


And in whatever method you chose to render:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. lldd.render( canvas );
  3.  
  4.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4


Any input highly appreciated !
Attachments
LowLevelDropDown.java
(9.78 KiB) Downloaded 103 times
There is no school like old school gaming.
Jompe71
Experienced Developer
Experienced Developer
 
Posts: 69
Joined: Sat Oct 25, 2008 2:21 pm
Location: Stockholm Sweden

Top

Return to Code Snippets for Android

Who is online

Users browsing this forum: No registered users and 3 guests