我正在开发一个游戏,我必须通过加速度计改变在屏幕底部的 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);