本文整理汇总了Java中org.andengine.extension.physics.box2d.PhysicsWorld类的典型用法代码示例。如果您正苦于以下问题:Java PhysicsWorld类的具体用法?Java PhysicsWorld怎么用?Java PhysicsWorld使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PhysicsWorld类属于org.andengine.extension.physics.box2d包,在下文中一共展示了PhysicsWorld类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLevel
import org.andengine.extension.physics.box2d.PhysicsWorld; //导入依赖的package包/类
@Override
public void createLevel(PhysicsWorld world, FixtureDef fixtureDef) {
int boxWidth = 30;
createBox(world, fixtureDef, 266, 343, boxWidth, 819, 45);
createBox(world, fixtureDef, 266, 343, boxWidth, 819, -45);
createBox(world, fixtureDef, 815, 345, boxWidth, 819, 45);
createBox(world, fixtureDef, 957, 204, boxWidth, 418, -45);
//--
int boxHeight = 30;
createBox(world, fixtureDef, 97, 1010, 191, boxHeight);
createBox(world, fixtureDef, 541, 1010, boxWidth, 819, 45);
createBox(world, fixtureDef, 633, 918, boxWidth, 1079, -45);
createBox(world, fixtureDef, 986, 1010, 191, boxHeight);
//--
createBox(world, fixtureDef, 266, 1653, boxWidth, 819, 45);
createBox(world, fixtureDef, 266, 1653, boxWidth, 819, -45);
createBox(world, fixtureDef, 958, 1799, boxWidth, 414, 45);
createBox(world, fixtureDef, 815, 1655, boxWidth, 819, -45);
}
示例2: createLevel
import org.andengine.extension.physics.box2d.PhysicsWorld; //导入依赖的package包/类
@Override
public void createLevel(PhysicsWorld world, FixtureDef fixtureDef) {
assertInitialized();
// lines at an angle
int boxWidth = 30;
int rotation = 45;
createBox(world, fixtureDef, 180, 454, boxWidth, 304, rotation);
createBox(world, fixtureDef, 492, 675, boxWidth, 403, -rotation);
createBox(world, fixtureDef, 180, 1058, boxWidth, 304, rotation);
createBox(world, fixtureDef, 492, 1292, boxWidth, 403, -rotation);
createBox(world, fixtureDef, 180, 1651, boxWidth, 304, rotation);
// middle line
createBox(world, fixtureDef, 635, 842, 30, 1685);
// lines at the right
int boxHeight = 30;
createBox(world, fixtureDef, 1004, 562, 154, boxHeight);
createBox(world, fixtureDef, 942, 1185, boxWidth, 1248);
}
示例3: createLevel
import org.andengine.extension.physics.box2d.PhysicsWorld; //导入依赖的package包/类
@Override
public void createLevel(PhysicsWorld world, FixtureDef fixtureDef) {
int boxWidth = 30;
createBox(world, fixtureDef, 212, 1081, boxWidth, 1678);
int boxHeight = 30;
for(int i = 0; i < 4; i++) {
if(i == 0) {
createBox(world, fixtureDef, 370, i * 385 + 257, 336, boxHeight);
} else {
createBox(world, fixtureDef, 385, i * 385 + 257, 366, boxHeight);
}
}
for(int i = 0; i < 3; i++) {
if(i == 0) {
createBox(world, fixtureDef, 784, 498, 294, boxHeight);
} else {
createBox(world, fixtureDef, 694, i * 386 + 448, 456, boxHeight);
}
}
createBox(world, fixtureDef, 652, 409, boxWidth, 177);
createOpenCircle(world, fixtureDef, 180, 360, 225, 877, 336, 30);
createBox(world, fixtureDef, 933, 955, boxWidth, 1279);
createOpenCircle(world, fixtureDef, 0, 180, 225, 870, 1591, 30);
}
示例4: createLevel
import org.andengine.extension.physics.box2d.PhysicsWorld; //导入依赖的package包/类
@Override
public void createLevel(PhysicsWorld world, FixtureDef fixtureDef) {
int boxWidth = 30;
createBox(world, fixtureDef, 534, 370, boxWidth, 742);
createOpenCircle(world, fixtureDef, -83, 76, 375, 636, 961, 30);
createOpenCircle(world, fixtureDef, -201, 115, 249, 640, 964, 20);
createOpenCircle(world, fixtureDef, 180, 398, 113, 647, 964, 20);
createOpenCircle(world, fixtureDef, 0, 175, 123, 411, 1048, 20);
createBox(world, fixtureDef, 534, 1309, boxWidth, 698);
int boxHeight = 30;
createBox(world, fixtureDef, 411, 1654, 278, boxHeight);
createBox(world, fixtureDef, 736, 1453, boxWidth, 282);
}
示例5: createLevel
import org.andengine.extension.physics.box2d.PhysicsWorld; //导入依赖的package包/类
@Override
public void createLevel(PhysicsWorld world, FixtureDef fixtureDef) {
int boxWidth = 30;
createBox(world, fixtureDef, 150, 1124, boxWidth, 1352);
int boxHeight = 30;
createBox(world, fixtureDef, 354, 463, 403, boxHeight);
for (int i = 0; i < 3; i++) {
createBox(world, fixtureDef, 469, i * 358 + 841, 636, boxHeight);
}
createBox(world, fixtureDef, 548, 1785, 797, boxHeight);
for (int i = 0; i < 3; i++) {
createBox(world, fixtureDef, 605, i * 358 + 662, 636, boxHeight);
}
createBox(world, fixtureDef, 930, 947, boxWidth, 1415);
}
示例6: createLevel
import org.andengine.extension.physics.box2d.PhysicsWorld; //导入依赖的package包/类
@Override
public void createLevel(PhysicsWorld world, FixtureDef fixtureDef) {
//small circle
createOpenCircle(world, fixtureDef, 270, 280.5f, 410, -18, 968, 5);
createOpenCircle(world, fixtureDef, -51.5f, 90, 410, -18, 968, 40);
//middle circle
createOpenCircle(world, fixtureDef, -90, 67.5f, 688, -29, 999, 50);
createOpenCircle(world, fixtureDef, 79, 90, 688, -29, 999, 10);
//big circle
createOpenCircle(world, fixtureDef, 270, 309, 904, -20, 999, 20);
createOpenCircle(world, fixtureDef, -43, 90, 904, -20, 999, 50);
createBox(world, fixtureDef, 540, 1904, 1080, 30);
}
示例7: Wall
import org.andengine.extension.physics.box2d.PhysicsWorld; //导入依赖的package包/类
public Wall(float pX, float pY, float pWidth, float pHeight, Type pType,
VertexBufferObjectManager pVertexBufferObjectManager, PhysicsWorld physicsWorld, boolean masked)
{
super(pX, pY, pWidth, pHeight, pVertexBufferObjectManager);
setVisible(false);
type = pType;
final FixtureDef itemFD;
if (masked) {
itemFD = PhysicsFactory.createFixtureDef(PhysicalWorldObject.BODY_DENSITY,
PhysicalWorldObject.BODY_ELASTICITY, PhysicalWorldObject.BODY_FRICTION,
false, GutGame.CATEGORY_WALL, GutGame.MASK_WALL, GutGame.GROUP_INDEX);
} else {
itemFD = PhysicsFactory.createFixtureDef(PhysicalWorldObject.BODY_DENSITY,
PhysicalWorldObject.BODY_ELASTICITY, PhysicalWorldObject.BODY_FRICTION);
}
Body body = PhysicsFactory.createBoxBody(physicsWorld, this, BodyDef.BodyType.StaticBody, itemFD);
body.setUserData(type);
body.setTransform(pX / PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT,
pY / PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT, 0);
physicsWorld.registerPhysicsConnector(new PhysicsConnector(this, body, true, false));
}
示例8: GameScene
import org.andengine.extension.physics.box2d.PhysicsWorld; //导入依赖的package包/类
public GameScene() {
physics = new PhysicsWorld(new Vector2(0, 0), true);
physics.setContactListener(this);
PillarFactory.getInstance().create(physics);
createBackground();
createActor();
createBounds();
createText();
res.camera.setChaseEntity(dandelion);
sortChildren();
setOnSceneTouchListener(this);
registerUpdateHandler(physics);
}
示例9: Pillar
import org.andengine.extension.physics.box2d.PhysicsWorld; //导入依赖的package包/类
public Pillar(float x, float y, TextureRegion reg, VertexBufferObjectManager vbom, PhysicsWorld physics) {
super(x, y);
pillarUp = new Sprite(0, shift, 96, 384, reg, vbom);
pillarUp.setFlippedVertical(true);
pillarUp.setAnchorCenterY(0);
attachChild(pillarUp);
pillarUpBody = PhysicsFactory.createBoxBody(physics, pillarUp, BodyType.StaticBody, Constants.WALL_FIXTURE);
pillarUpBody.setUserData(Constants.BODY_WALL);
pillarDown = new Sprite(0, -shift, 96, 384, reg, vbom);
pillarDown.setAnchorCenterY(1);
attachChild(pillarDown);
pillarDownBody = PhysicsFactory.createBoxBody(physics, pillarDown, BodyType.StaticBody, Constants.WALL_FIXTURE);
pillarDownBody.setUserData(Constants.BODY_WALL);
Rectangle r = new Rectangle(0, 0, 1, 9999, vbom); // just to make sure it's big
r.setColor(Color.GREEN);
r.setAlpha(0f);
attachChild(r);
scoreSensor = PhysicsFactory.createBoxBody(physics, r, BodyType.StaticBody, Constants.SENSOR_FIXTURE);
scoreSensor.setUserData(Constants.BODY_SENSOR);
}
示例10: createPhysics
import org.andengine.extension.physics.box2d.PhysicsWorld; //导入依赖的package包/类
private void createPhysics(final Camera camera, PhysicsWorld physicsWorld)
{
body = PhysicsFactory.createCircleBody(physicsWorld, this, BodyType.DynamicBody, PhysicsFactory.createFixtureDef(0, 0, 0));
//body = PhysicsFactory.createBoxBody(physicsWorld, this, BodyType.DynamicBody, PhysicsFactory.createFixtureDef(0,0,0));
body.setUserData("player");
body.setFixedRotation(true);
physicsWorld.registerPhysicsConnector(new PhysicsConnector(this,body,true,false)
{
@Override
public void onUpdate(float pSecondsElapsed)
{
super.onUpdate(pSecondsElapsed);
camera.onUpdate(0.1f);
if(getY()<=0)
{
onDie();
}
}
});
}
示例11: init
import org.andengine.extension.physics.box2d.PhysicsWorld; //导入依赖的package包/类
@Override
public void init(GameLevel gameLevel, PhysicsWorld physicsWorld, Engine engine) {
_gameLevel = gameLevel;
_physicsWorld = physicsWorld;
_engine = engine;
_contactListener = new ContactListenerAdapter() {
@Override
public void beginContact(Contact contact) {
checkCollision(contact);
}
};
_physicsWorld.setContactListener(_contactListener);
}
示例12: init
import org.andengine.extension.physics.box2d.PhysicsWorld; //导入依赖的package包/类
@Override
public void init(GameLevel gameLevel, PhysicsWorld physicsWorld, Engine engine) {
super.init(gameLevel, physicsWorld, engine);
float camHeight = engine.getCamera().getHeight();
float originalHeight = 1920;
float heightScale = camHeight / originalHeight;
Typeface typeFace = Typeface.createFromAsset(GoogleFlipGameApplication.sContext.getAssets(), FontFaceType.FUTURA_BOOK.getAssetName());
Font explanationFont = FontFactory.create(_engine.getFontManager(), _engine.getTextureManager(), 512, 768, TextureOptions.BILINEAR, typeFace, (int) 20 * GoogleFlipGameApplication.sContext.getResources().getDisplayMetrics().density, Color.WHITE_ABGR_PACKED_INT);
explanationFont.load();
_engine.getFontManager().loadFont(explanationFont);
Vector2 textPoint = Vector2Pool.obtain(_engine.getCamera().getWidth() / 2, _engine.getCamera().getHeight() * .70f);
String explanation1, explanation2;
switch (GoogleFlipGameApplication.getUserModel().getTutorialLevel()) {
case 1:
explanation1 = GoogleFlipGameApplication.sContext.getResources().getString(R.string.tutorial_2a);
explanation2 = GoogleFlipGameApplication.sContext.getResources().getString(R.string.tutorial_2b);
break;
case 2:
explanation1 = GoogleFlipGameApplication.sContext.getResources().getString(R.string.tutorial_3);
explanation2 = "";
break;
default:
explanation1 = GoogleFlipGameApplication.sContext.getResources().getString(R.string.tutorial_1a);
explanation2 = GoogleFlipGameApplication.sContext.getResources().getString(R.string.tutorial_1b);
break;
}
_explanationText1 = new Text(textPoint.x, textPoint.y, explanationFont, explanation1, new TextOptions(HorizontalAlign.CENTER), _engine.getVertexBufferObjectManager());
_explanationText2 = new Text(textPoint.x, textPoint.y - (_explanationText1.getHeight()), explanationFont, explanation2, new TextOptions(HorizontalAlign.CENTER), _engine.getVertexBufferObjectManager());
_engine.getScene().attachChild(_explanationText1);
_engine.getScene().attachChild(_explanationText2);
}
示例13: createLevel
import org.andengine.extension.physics.box2d.PhysicsWorld; //导入依赖的package包/类
@Override
public void createLevel(PhysicsWorld world, FixtureDef fixtureDef) {
int boxHeight = 30;
createBox(world, fixtureDef, 225, 1907, 454, boxHeight);
createBox(world, fixtureDef, 463, 347, 205, boxHeight, 45);
int boxWidth = 30;
createBox(world, fixtureDef, 425, 456, boxWidth, 485, 45);
createBox(world, fixtureDef, 482, 721, boxWidth, 311, -45);
createBox(world, fixtureDef, 482, 922, boxWidth, 311, 45);
createBox(world, fixtureDef, 475, 1128, boxWidth, 300, -45);
createBox(world, fixtureDef, 481, 1325, boxWidth, 311, 45);
createBox(world, fixtureDef, 490, 1515, boxWidth, 266, -45);
createBox(world, fixtureDef, 490, 1694, boxWidth, 282, 45);
createBox(world, fixtureDef, 502, 1860, boxWidth, 249, -45);
createOpenCircle(world, fixtureDef, -90, 50, 130, 618, 195, 30);
createBox(world, fixtureDef, 650, 350, 200, boxHeight, 47);
createBox(world, fixtureDef, 688, 515, boxWidth, 311, 45);
createBox(world, fixtureDef, 683, 718, boxWidth, 317, -45);
createBox(world, fixtureDef, 682, 920, boxWidth, 311, 45);
createBox(world, fixtureDef, 678, 1123, boxWidth, 315, -45);
createBox(world, fixtureDef, 681, 1328, boxWidth, 289, 45);
createBox(world, fixtureDef, 702, 1490, boxWidth, 201, -45);
createBox(world, fixtureDef, 986, 422, 192, boxHeight);
}
示例14: createLevel
import org.andengine.extension.physics.box2d.PhysicsWorld; //导入依赖的package包/类
@Override
public void createLevel(PhysicsWorld world, FixtureDef fixtureDef) {
assertInitialized();
int boxHeight = 30;
createBox(world, fixtureDef, 633, 495, 615, boxHeight, 45);
int boxWidth = 30;
createBox(world, fixtureDef, 767, 1042, boxWidth, 943, 45);
createBox(world, fixtureDef, 407, 1086, boxWidth, 1209, 45);
createBox(world, fixtureDef, 372, 1435, 538, boxHeight, 45);
createBox(world, fixtureDef, 717, 1623, 352, boxHeight, 45);
}
示例15: createLevel
import org.andengine.extension.physics.box2d.PhysicsWorld; //导入依赖的package包/类
@Override
public void createLevel(PhysicsWorld world, FixtureDef fixtureDef) {
int boxHeight = 30;
createBox(world, fixtureDef, 115, 313, 278, boxHeight);
createBox(world, fixtureDef, 827, 313, 573, boxHeight);
createBox(world, fixtureDef, 263, 620, 573, boxHeight);
createBox(world, fixtureDef, 974, 620, 277, boxHeight);
createBox(world, fixtureDef, 722, 928, 732, boxHeight);
createBox(world, fixtureDef, 432, 1236, 895, boxHeight);
createBox(world, fixtureDef, 640, 1543, 906, boxHeight);
}