簡體   English   中英

如何獲取以米為單位的PhysicsWorld的精確高度和寬度?

[英]How to get exact height and Width of PhysicsWorld in Meters?

我正在研究AndEngine,並且想知道以米為單位的PhysicsWorld的確切高度和寬度。

    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;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM