Box2D Flash on Mobile Android

I recently started using an Android 2.2 OS phone which has Flash 10. I’ve been toying with developing simple demos to test out the Flash capabilities of the phone. Then I decided to test out a simple Box2D demo I made as a modification of the demo by plasticsturgeon. Box2DFlash is an open source Physics Engine. Check it out. I look forward to working with it more in the future.

The demo ran quite smooth on the phone surprisingly staying close to 30 fps.

Below is the demo, but to get the full effect browse to the link using an Android 2.2 phone with Flash 10 installed.

mobile link: http://www.lostvectors.com/mobile/test4

Get Adobe Flash player

Modifications to the original demo by plasticsturgeon.com:

– Click (touch) to full screen mode.
– Zoomed camera focused view that pans with the target body
– Bodies jump as soon as they fall asleep

Here’s another mod I created to test user control of a single body using keyboard input. Use WASD to control the focused body (W is Jump). Note: this demo is intended for desktop computer with a keyboard and not a mobile device.

Get Adobe Flash player

User Controlled Body Mod Features:

– Added “hero unit” user control of a single body using speed-capped impulse
– Detected edge collision to allow jumping only when grounded

To view this in it’s own window visit http://www.lostvectors.com/box2d/demo1

Resources:
Box2DFlash
Plastic Sturgeon Box2D Hello World Demo
Flash Sizing Zen

Bookmark the permalink.

7 Responses to Box2D Flash on Mobile Android

  1. Mystyr Nile says:

    Awesome!
    Let’s look forward to the future!
    *looks straight ahead*

    Thumb up 0 Thumb down 1

  2. This is nice. I really like the zoomed camera effect. Its like being inside a popcorn machine.

    Thumb up 0 Thumb down 0

    • Jason says:

      :) Why thank you — basically I modified it so there’s no such thing as “rest” — As soon as they are rested I punt them with a velocity change… a bit cruel I suppose.

      Camera zoom was accomplished with using localToGlobal/globalToLocal and setting the scale of the main box environment display list to larger than a 100%

      Thumb up 0 Thumb down 0

  3. J4ck4l says:

    one thing i noticed was that it didnt matter what edge was touching on the hero unit. so you could just press against the wall and jump. you probably noticed that but just wanted to say it.

    Thumb up 0 Thumb down 0

  4. Esdras says:

    post legal mas eu acho que deveriam fazer um jogo de multiplayer para os outros poderem jogar uns contra os outros , isso seria bom bastante bom

    Thumb up 0 Thumb down 0

  5. Carlos says:

    I’m still imo a novice developer. A few of my friends and I have been developing a platformer in flash using Box2d and I want to port it over to my android phone (to see where we can actually take this). I have a nice demo set up and I’m not sure how to add the android touch option to the game. I want to add on-screen controls to move the character around, etc. I would just like to know where to look to find out how to do this. And if this requires the android sdk or ndk.

    Thumb up 0 Thumb down 0

    • Jason says:

      Creating virtual thumb sticks and buttons don’t require any special Android sdk code calls. You need to use TouchEvent and MultitouchInputMode (see as3 reference docs). But in order to test that code you need to deploy it to a touch device. And that does require you to have the android sdk installed for the mobile driver and have have flash CS5 or CS5.5.

      Thumb up 0 Thumb down 0

Leave a Reply

Your email address will not be published. Required fields are marked *


*