在船上滑动球

时间:2014-03-03 04:55:01

标签: android libgdx box2d

实现enter image description here的第1张

我能做的是一些图片2(方形体倾斜使球向下滑动),

public Body createCArea() {
        PolygonShape cShape = new PolygonShape();
        int value = 10;
        Vector2[] cVert = new Vector2[4];
        cVert[0] = new Vector2(90, 100);// -6,2
        cVert[1] = new Vector2(180, 55);// -2,6
        cVert[2] = new Vector2(-90, -100);// 2,6
        cVert[3] = new Vector2(-180, -55);//
        cShape.set(cVert);
        BodyDef standBodyDef = new BodyDef();
        standBodyDef.type = BodyType.StaticBody;
        standBodyDef.position.set(camera.viewportWidth * .55f, 170);
        FixtureDef standFixture = new FixtureDef();
        standFixture.shape = cShape;
        standFixture.density = 10;
        standFixture.friction = 0.3f;
        standFixture.restitution = 0f;

        Body standBody = world.createBody(standBodyDef);
        standBody.createFixture(createFixture(cShape));
        return standBody;
    }

public Body createBall()
    {
        BodyDef roundbody = new BodyDef();
        //  roundbody.position.set(new Vector2(0, 50));
            roundbody.type=BodyType.DynamicBody;
            roundbody.position.set(camera.viewportWidth * .60f, 260);
            Body rbody = world.createBody(roundbody);
            CircleShape dynamicCircle = new CircleShape();
            dynamicCircle.setRadius(15f);



            fixtureDef.shape = dynamicCircle;
            fixtureDef.density = 2f;
            fixtureDef.friction = 0.9f;
            fixtureDef.restitution = 0;
            rbody.createFixture(fixtureDef);
            return rbody;

    }

所以我应该怎么做pic 1,是否可能,在方框2d中新增

0 个答案:

没有答案