2013-12-09 4 views
0

안드로이드에 대한 Andengine에서 데모를 만들고 있는데 Galaxy SIII에서 게임을 실행하면 화면이 엉망입니다. 이 공이며, 그것은 몇 번을 반송하도록되어 있지만 내가 그것을 실행할 때 그것은 불규칙적 색상과 같이 표시하고, 공을 반으로 분할되고 screen.Here 주위의 모든 내 코드입니다 : 내가 시험Andengine android에서 화면이 깜박입니다. 어떻게 고치는 지?

package com.example.andeng2; 

import org.andengine.engine.camera.Camera; 
import org.andengine.engine.options.EngineOptions; 
import org.andengine.engine.options.ScreenOrientation; 
import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy; 
import org.andengine.entity.primitive.Rectangle; 
import org.andengine.entity.scene.Scene; 
import org.andengine.entity.scene.background.Background; 
import org.andengine.entity.sprite.Sprite; 
import org.andengine.extension.physics.box2d.PhysicsConnector; 
import org.andengine.extension.physics.box2d.PhysicsFactory; 
import org.andengine.extension.physics.box2d.PhysicsWorld; 
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas; 
import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory; 
import org.andengine.opengl.texture.region.ITextureRegion; 
import org.andengine.ui.activity.BaseGameActivity; 
import org.andengine.util.color.Color; 

import android.hardware.SensorManager; 

import com.badlogic.gdx.math.Vector2; 
import com.badlogic.gdx.physics.box2d.Body; 
import com.badlogic.gdx.physics.box2d.BodyDef.BodyType; 
import com.badlogic.gdx.physics.box2d.FixtureDef; 

public class MainActivity extends BaseGameActivity { 

    Scene scene; 
    protected static final int CAMERA_WIDTH = 720; 
    protected static final int CAMERA_HEIGHT = 480; 
    BitmapTextureAtlas playerTexture; 
    ITextureRegion playerTextureRegion; 
    PhysicsWorld physicsWorld; 

    @Override 
    public EngineOptions onCreateEngineOptions() { 
     // TODO Auto-generated method stub 
     Camera mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT); 
     EngineOptions options = new EngineOptions(true, 
       ScreenOrientation.LANDSCAPE_FIXED, new RatioResolutionPolicy(
         CAMERA_WIDTH, CAMERA_HEIGHT), mCamera); 
     return options; 
    } 

    @Override 
    public void onCreateResources(
      OnCreateResourcesCallback pOnCreateResourcesCallback) 
      throws Exception { 
     // TODO Auto-generated method stub 
     loadGfx(); 
     // resources have been loaded 
     pOnCreateResourcesCallback.onCreateResourcesFinished(); 

    } 

    private void loadGfx() { 
     // TODO Auto-generated method stub 
     BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/"); 
     // width and height have to be power of 2^x 
     playerTexture = new BitmapTextureAtlas(getTextureManager(), 64, 64); 
     playerTextureRegion = BitmapTextureAtlasTextureRegionFactory 
       .createFromAsset(playerTexture, this, "player.png", 0, 0); 
     playerTexture.load(); 

    } 

    @Override 
    public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) 
      throws Exception { 
     // TODO Auto-generated method stub 
     this.scene = new Scene(); 
     this.scene.setBackground(new Background(0f, 125f, 58f)); 
     physicsWorld = new PhysicsWorld(new Vector2(0,SensorManager.GRAVITY_EARTH), false); 
     this.scene.registerUpdateHandler(physicsWorld); 
     createWalls(); 
     pOnCreateSceneCallback.onCreateSceneFinished(this.scene); 

    } 

    private void createWalls() { 
     // TODO Auto-generated method stub 
     FixtureDef WALL_FIX = PhysicsFactory.createFixtureDef(0.0f, 0.0f, 0.0f); 
     Rectangle ground = new Rectangle(0, CAMERA_HEIGHT-15, CAMERA_WIDTH, 15, this.mEngine.getVertexBufferObjectManager()); 
     ground.setColor(new Color(15,50,0)); 
     PhysicsFactory.createBoxBody(physicsWorld, ground, BodyType.StaticBody, WALL_FIX); 
     this.scene.attachChild(ground); 

    } 

    @Override 
    public void onPopulateScene(Scene pScene, 
      OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception { 
     // TODO Auto-generated method stub 
     Sprite sPlayer = new Sprite(CAMERA_WIDTH/2, CAMERA_HEIGHT/2, playerTextureRegion, this.mEngine.getVertexBufferObjectManager()); 
     sPlayer.setRotation(45.0f); 
     final FixtureDef PLAYER_FIX = PhysicsFactory.createFixtureDef(10.0f, 1.0f, 0.0f); 
     Body body = PhysicsFactory.createCircleBody(physicsWorld, sPlayer, BodyType.DynamicBody, PLAYER_FIX); 
     this.scene.attachChild(sPlayer); 
     physicsWorld.registerPhysicsConnector(new PhysicsConnector(sPlayer, body, true, false)); 
      pOnPopulateSceneCallback.onPopulateSceneFinished(); 

    } 
} 

답변

1

S3 장치에서 나는 깜박 거리는 것을 발견하지 못했습니다. 당신이 player.png 큰 이미지를 Texture로로드하기가 어렵다고 생각합니다. 한 번 확인하십시오. 그렇다면 이미지 크기에 따라 bitmapTextureatlas 입력을 변경하십시오.

관련 문제