나는 android canvas를 사용하여 만든 라이브 배경 화면을 가지고 있습니다. 테스트를 통해 OpenGL의 힘을 활용하는 것이 필요하다고 느꼈으 며 AndEngine을 실험하고 있습니다. 나는 내가 어떻게 다음과 같은 것을 성취 할 수 있는지 궁금합니다.AndEngine 업데이트 화면
@Override
public void onLoadResources()
{
mtexture = new Texture(1024, 1024, TextureOptions.BILINEAR);
TextureRegionFactory.setAssetBasePath("gfx/");
mtextureRegion = TextureRegionFactory.createFromResource(mtexture , this, R.drawable.background1, 0, 0);
this.mEngine.getTextureManager().loadTexture(this.mtexture);
}
@Override
public Scene onLoadScene(){
final Scene scene = new Scene(1);
Sprite background = new Sprite(0, 0, CAMERA_WIDTH*2, CAMERA_HEIGHT, mtextureRegion)
SpriteBackground sb = new SpriteBackground(background);
scene.setBackground(sb);
scene.setBackgroundEnabled(true);
return scene;
}
이를 :
나는 맨 (안 움직이는 운동)
지금까지 내가 배경 이미지이이 위에 떠있는 많은 작은 비트 맵, 전체 화면을 채우는 배경 이미지를 가지고 배경에는 잘 작동하지만 스프라이트는 움직여야합니다.
void drawFrame() {
final SurfaceHolder holder = getSurfaceHolder();
Canvas c = null;
try {
c = holder.lockCanvas();
if (c != null) {
//draw
}
} finally {
if (c != null) holder.unlockCanvasAndPost(c);
}
mHandler.removeCallbacks(drawScreen);
mHandler.postDelayed(drawScreen, 10);
}
적절한 방법은 무엇입니까 - 내 캔버스 코드에서
, 나는 위치를 이동 객체의 & 물리학을 업데이트하고 캔버스마다 몇 MS private final Runnable drawScreen = new Runnable() {
public void run() {
drawFrame();
}};
을 끌기 위해 다음을 수행 AndEngine에서이 작업을 수행할까요? 같은 코드를 사용하고 OpenGL 호출을 대신 사용합니까?
내가 GLEngine
을보고 있는데, Runnables를 GlThread
대기열로 보냈겠습니까?
편집 - 내가 대답을 찾은 것 같아요 ... UpdateHandler. 그러나 업데이트 처리기 (즉, onUpdate
메서드 호출)에 어떻게 알릴 수 있습니까? Timed Handler를 만들면 너무 자주 호출하면 어떻게됩니까? 요청 대기열이 쌓입니까?