私はandengineアプリケーションに取り組んでいます。これでは、ユーザーのクリック時にスプライトを挿入し、小さな四角形を使用して円を描きます。ループで四角形をたくさん作って円のパス上に並べると円に見えます。しかし、問題は、画面の反応が遅く、ぶら下がっているように見えることです.誰かがそれをよりスムーズにする方法を提案できますか..これが私のコードです.
//変数
private static final FixtureDef FIXTURE_DEF = PhysicsFactory.createFixtureDef(1, 0.5f, 0.5f);
private BitmapTextureAtlas mBitmapTextureAtlas;
private TiledTextureRegion mBoxFaceTextureRegion;
private Scene mScene;
private PhysicsWorld mPhysicsWorld;
//シーンメソッド
@Override
public Scene onCreateScene() {
this.mEngine.registerUpdateHandler(new FPSLogger());
this.mScene = new Scene();
this.mScene.setBackground(new Background(0, 0, 0));
this.mScene.setOnSceneTouchListener(this);
this.mPhysicsWorld = new PhysicsWorld(new Vector2(0, SensorManager.GRAVITY_EARTH), false);
final VertexBufferObjectManager vertexBufferObjectManager = this.getVertexBufferObjectManager();
final Rectangle ground = new Rectangle(0, CAMERA_HEIGHT - 2, CAMERA_WIDTH, 2, vertexBufferObjectManager);
final Rectangle roof = new Rectangle(0, 0, 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);
final FixtureDef wallFixtureDef = PhysicsFactory.createFixtureDef(0, 0.5f, 0.5f);
PhysicsFactory.createBoxBody(this.mPhysicsWorld, ground, BodyType.StaticBody, wallFixtureDef);
PhysicsFactory.createBoxBody(this.mPhysicsWorld, roof, BodyType.StaticBody, wallFixtureDef);
PhysicsFactory.createBoxBody(this.mPhysicsWorld, left, BodyType.StaticBody, wallFixtureDef);
PhysicsFactory.createBoxBody(this.mPhysicsWorld, right, BodyType.StaticBody, wallFixtureDef);
this.mScene.attachChild(ground);
this.mScene.attachChild(roof);
this.mScene.attachChild(left);
this.mScene.attachChild(right);
drawLine();
this.mScene.registerUpdateHandler(this.mPhysicsWorld);
return this.mScene;
}
// drawline メソッド内:
private void drawLine() {
float x1,y1,x2=1,y2=1;
float r=100;
float xCenter=300,yCenter=300;
Rectangle rectTest;
for(double i=0;i<5;i+=.01){
x1 = (float) (xCenter + r * Math.cos(i));
y1 = (float) (yCenter + r * Math.sin(i));
System.out.println("RECT x1="+x1);
System.out.println("RECT y1="+y1);
System.out.println("RECT x2="+x2);
System.out.println("RECT y3="+y2);
rectTest = new Rectangle(x1,y1,1,1,getVertexBufferObjectManager());
rectTest.setColor(Color.RED);
FixtureDef wallFixtureDef = PhysicsFactory.createFixtureDef(0,
0.1f, 0.1f);
PhysicsFactory.createBoxBody(this.mPhysicsWorld, rectTest,
BodyType.StaticBody, wallFixtureDef);
this.mScene.attachChild(rectTest);
}
}