Detailed explanation of jbox2d engine for Android (continuously updated)

Source: Internet
Author: User

Preface:This blog post explains how to use jbox2d 2.1.2 on the Android platform. There are very few tutorials on jbox2d on the Internet, and there are fewer tutorials related to Android. I have been studying jbox2d for more than a month.
The engine is really good. It is an excellent simulation of the stress of the real world. The Angry Birds that swept the world some time ago were made with the box2d engine! I am using the version is jbox2d-2.1.2, the official forum to download this version is not available in Android platform, there are some small errors, later, after a period of research, I modified the source code to compile a jar package suitable for the Android platform, and the efficiency was optimized!


Download Engine: jbox2d4android_2.1.2.1

Section 1 create a physical world:

Box2d is actually a real physical world, and a world needs a range (of course, our world does not know that there is a range). The Versions earlier than box2d2.1.2 have a boundary concept, 2.1.2 is no longer available, more relevant to the concept of the physical world!

First lookCode

World; // The World object vec2 gravity = new vec2 (0.0f, 10.0f); // The World's gravity is: X axis, Y axis, here we give 10 N/m2 a little bigger than the real world = New World (gravity, true); // create the world: gravity, whether to allow static objects to sleep

This physical world has been created!

Joint Learning 1. Weld Joints: Weldjoint: Used to fix two objects

Creation method:

 
Weldjointdef jointdef = new weldjointdef (); jointdef. initialize (body, body2, vec2); // vec2: Fixed Points of two objects
 
World. createjoint (jointdef );

To be continued...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.