Android MOGA controller menu handling

I’m developing the menu handling for the MOGA controller in my maze game MultiMaze. When the KEYCODE_DPAD_UP button is pressed I want to change focus to the button below the current button. I had some trouble finding a nextFocus method but I’ve now found the excellent getNextFocusDownId method.

So I’ll specify a button in the XML like this:

 
    <Button
        android:id="@+id/multiplayer_button"
        android:focusable="true"
        android:focusableInTouchMode="true"

        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/singleplayer_button"
        android:text="@string/main_menu_multiplayer_text"/>

Then when I detect a DPAD_UP signal I’ll focus the button above with the following code:

Button upButton = (Button)findViewById(multiplayerButton.getNextFocusUpId());
upButton.requestFocus();

Android MOGA Game controller implementation

I’ve started looking on implementing the MOGA game controller to MultiMaze!

To get something working I ripped out the controller logic from a sample project downloaded from here
controller-sdk-std-1.3.1 2/controller-sdk-std-1.3.0.130201/controller-sdk-std/samples/com.bda.controller.example.demo.listen

Now I’m not using the standard Android InputDevice method but a MOGA library. My dream was to implement the MOGA controller and then MultiMaze would kind-of support all controllers but this will not be the case with this solution.

So I got the actual game logic to work with the controller, i.e. moving north, east, south, west, up, down and back, using the D(irectional)-PAD and the A(up/down) and B(back) buttons. Now I’ve got to make a nice solution so that the user can also navigate the menus and dialogs.

Progress so far:

Good MOGA Pro Controller FAQ

Here’s a good intro to Android game controllers:

Transforming DrawableAnimation Android

Today I added a flash screen to MultiMaze. On the screen I wanted to have a MultiMaze “player” run across the screen. This is how I achieved it:

// Animate the players fluttering cape
ImageView playerImageView = (ImageView)this.findViewById(R.id.player);
AnimationDrawable playerFlutterAnimation = new AnimationDrawable();
Drawable p1 = this.getResources().getDrawable(R.drawable.player_1);
Drawable p2 = this.getResources().getDrawable(R.drawable.player_2);
playerFlutterAnimation.addFrame(p1, 200);
playerFlutterAnimation.addFrame(p2, 200);
playerFlutterAnimation.setOneShot(false);
playerImageView.setImageDrawable(playerFlutterAnimation);
playerFlutterAnimation.start();

// Animate player movement from left to right
ObjectAnimator playerMoveAnimation = 
   ObjectAnimator.ofFloat(playerImageView, "translationX", -100f, 1000f);
playerMoveAnimation.setDuration(3000);
playerMoveAnimation.start();

The result:

China loves MultiMaze!

Got my first real user boost yesterday. Usually I have around 20 installs per day. Yesterday that number was 128! Almost all the new users come from China, so a localized version of MM in simplified Chinese is a priority now! That and an improved South Korean version. The surge of new users resulted in a new Premium purchase! A good start of the new year! :)

peak_mm