私はズームカメラのHUDにいくつかのクリック可能なスプライトを配置しようとしています。 Spriteは、ZoomCameraが元の位置に置かれている場合に限り、タッチイベントをうまく検出します。ズームカメラが元の位置から移動した場合、HUDのスプライトボタンがタッチイベントを検出しません
カメラをズームインしたりパンしたりすると、タッチ領域がカメラではなく、シーンを基準にしてその領域に残っているように見えます。したがって、スプライトが元の状態で存在していた領域をクリックした場合にのみ動作します。
これは、関連するコードの大部分である -
FloorSelectorButton firstButton = new FloorSelectorButton(0, 100, 80, 80,
this.getVertexBufferObjectManager(), 3, this);
FloorSelectorButton secondButton = new FloorSelectorButton(0, 180, 80, 80,
this.getVertexBufferObjectManager(), 2, this);
FloorSelectorButton thirdButton = new FloorSelectorButton(0, 260, 80, 80,
this.getVertexBufferObjectManager(), 1, this);
mScene = new Scene();
mScene.setOnAreaTouchTraversalFrontToBack();
HUD hud = new HUD();
mZoomCamera.setHUD(hud);
hud.attachChild(firstButton);
hud.attachChild(secondButton);
hud.attachChild(thirdButton);
hud.registerTouchArea(firstButton);
hud.registerTouchArea(secondButton);
hud.registerTouchArea(thirdButton);
this.mScrollDetector = new SurfaceScrollDetector(this);
this.mPinchZoomDetector = new PinchZoomDetector(this);
this.mScene.setOnSceneTouchListener(this);
this.mScene.setTouchAreaBindingOnActionDownEnabled(true);
return mScene;
FloorSelectorButtonは、スプライトを拡張しonAreaTouch方法を実装するだけのクラスです。
私は皆さんが私の手助けをしてくれることを願っています!
ありがとうございます!
これは間違いなく、これは自分自身のような初心者AndEngine開発者のよくある間違いです。したがって、皆さんにお気をつけて、TouchAreaを正しいシーンに設定してください! – JohnEye