gpt4 book ai didi

java - 如何获得物理世界的精确高度和宽度(以米为单位)?

转载 作者:行者123 更新时间:2023-12-01 11:58:05 25 4
gpt4 key购买 nike

我正在开发 AndEngine,并且一直想知道我使用的物理世界的准确高度和宽度(以米为单位)。

    this.mScene = new Scene();
this.mScene.setBackground(new Background(0, 0, 0));
this.mScene.setOnSceneTouchListener(this);
this.mScene.setOnAreaTouchListener(this);

this.mPhysicsWorld = new PhysicsWorld(new Vector2(0, 10), false);
this.mScene.registerUpdateHandler(this.mPhysicsWorld);

最佳答案

我用我的方式解决了这个问题..谢谢@LearnCocos2D。

        this.mScene = new Scene();
this.mScene.setBackground(new Background(0, 0, 0));
this.mScene.setOnSceneTouchListener(this);
this.mScene.setOnAreaTouchListener(this);

this.mPhysicsWorld = new PhysicsWorld(new Vector2(0, 10), false);
this.mScene.registerUpdateHandler(this.mPhysicsWorld);

final Rectangle ground = new Rectangle(0, CAMERA_HEIGHT - 2, CAMERA_WIDTH, 2, vertexBufferObjectManager);
final Rectangle left = new Rectangle(0, 0, 2, CAMERA_HEIGHT, vertexBufferObjectManager);
final Rectangle right = new Rectangle(CAMERA_WIDTH - 2, 0, 2, CAMERA_HEIGHT, vertexBufferObjectManager);
Body g =PhysicsFactory.createBoxBody(this.mPhysicsWorld, ground, BodyType.StaticBody, wallFixtureDef2);
Body l =PhysicsFactory.createBoxBody(this.mPhysicsWorld, left, BodyType.StaticBody, wallFixtureDef1);

final float width = 2*g.getWorldCenter().x;
final float height = 2*l.getWorldCenter().y;

关于java - 如何获得物理世界的精确高度和宽度(以米为单位)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28272847/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com