我正在开发一款游戏,我必须通过加速度计更换在屏幕底部的x轴上移动一个篮状多边形体。
水平棱柱连接是连接右墙体和篮体。游戏开始时,篮体向墙壁移动并停止....
如何让它在加速度计值变化上移动?
prismaticJointDef.initialize(rightwallbody, manBody, manBody.getWorldCenter(), new Vector2(1f,0f));
prismaticJointDef.collideConnected = false;
prismaticJointDef.enableLimit = true;
prismaticJointDef.localAxis1.nor();
prismaticJointDef.localAxis1.set(1,0);
prismaticJointDef.lowerTranslation = -150f / PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT;
prismaticJointDef.upperTranslation = 150f / PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT;
prismaticJointDef.enableMotor = true;
prismaticJointDef.maxMotorForce = 100f;
prismaticJointDef.motorSpeed = 0.1f;
mPhysicsWorld.createJoint(prismaticJointDef);