我目前创建了一个动态的主体,并使用Vector2()以恒定速度移动.我想要的是当身体离开屏幕边缘时,瞬间从当前点回到原点.我该怎么做呢?
a.applyForceToCenter(aMovement, true);
a.applyTorque(3000, true);
FixtureDef fDef = new FixtureDef();
BodyDef ballD = new BodyDef();
ballD.type = BodyType.DynamicBody;
//random location for asteroid
int aLoc = (int) (aLocation * 15);
float x = 300;
switch(aLoc)
{
case 0:
ballD.position.set(x, -105);
break;
case 1:
ballD.position.set(x, -95);
break;
case 2:
ballD.position.set(x, -80);
break;
case 3:
ballD.position.set(x, -65);
break;
case 4:
ballD.position.set(x, -50);
break;
case 5:
ballD.position.set(x, -35);
break;
case 6:
ballD.position.set(x, -20);
break;
case 7:
ballD.position.set(x, -5);
break;
case 8:
ballD.position.set(x, 10);
break; …
Run Code Online (Sandbox Code Playgroud) 如何保存一个可以覆盖的整数,然后在android上读取它?我正在使用libgdx.我知道如何为我的桌面做这件事,但我想要内部存储.