Pan scene with scroll gesture
This commit is contained in:
Binary file not shown.
+1
-1
Submodule hyperlap2d-common-api updated: 7813a24acf...da97d4e9d5
+2
-2
@@ -56,8 +56,8 @@ public class DeleteTileTool implements Tool {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stageMouseScrolled(float amountX, float amountY) {
|
||||
|
||||
public boolean stageMouseScrolled(float amountX, float amountY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -67,8 +67,8 @@ public class DrawTileTool implements Tool {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stageMouseScrolled(float amountX, float amountY) {
|
||||
|
||||
public boolean stageMouseScrolled(float amountX, float amountY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -431,19 +431,20 @@ public class SandboxMediator extends Mediator<Sandbox> {
|
||||
public boolean scrolled(Entity entity, float amountX, float amountY) {
|
||||
Sandbox sandbox = Sandbox.getInstance();
|
||||
// well, duh
|
||||
if (amountX == 0) return false;
|
||||
if (amountX == 0 && amountY == 0) return false;
|
||||
|
||||
// Control pressed as well
|
||||
if (isControlPressed()) {
|
||||
float zoomPercent = sandbox.getZoomPercent();
|
||||
zoomPercent-= amountX *4f;
|
||||
zoomPercent-= amountY * 4f;
|
||||
if(zoomPercent < 5 ) zoomPercent = 5;
|
||||
|
||||
sandbox.setZoomPercent(zoomPercent, true);
|
||||
}
|
||||
|
||||
if (currentSelectedTool != null) {
|
||||
currentSelectedTool.stageMouseScrolled(amountX, amountY);
|
||||
} else {
|
||||
if (currentSelectedTool != null
|
||||
&& !currentSelectedTool.stageMouseScrolled(amountX, amountY)) {
|
||||
viewComponent.panSceneBy(amountX * 10f, -amountY * 10f);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -4,20 +4,20 @@ import com.badlogic.ashley.core.Entity;
|
||||
|
||||
public interface InputListener {
|
||||
|
||||
public boolean keyDown(Entity entity, int keycode);
|
||||
boolean keyDown(Entity entity, int keycode);
|
||||
|
||||
public boolean keyUp(Entity entity, int keycode);
|
||||
boolean keyUp(Entity entity, int keycode);
|
||||
|
||||
public boolean keyTyped(Entity entity, char character);
|
||||
boolean keyTyped(Entity entity, char character);
|
||||
|
||||
public boolean touchDown(Entity entity, float screenX, float screenY, int pointer, int button);
|
||||
boolean touchDown(Entity entity, float screenX, float screenY, int pointer, int button);
|
||||
|
||||
public void touchUp(Entity entity, float screenX, float screenY, int pointer, int button);
|
||||
void touchUp(Entity entity, float screenX, float screenY, int pointer, int button);
|
||||
|
||||
public void touchDragged(Entity entity, float screenX, float screenY, int pointer);
|
||||
void touchDragged(Entity entity, float screenX, float screenY, int pointer);
|
||||
|
||||
public boolean mouseMoved(Entity entity, float screenX, float screenY);
|
||||
boolean mouseMoved(Entity entity, float screenX, float screenY);
|
||||
|
||||
public boolean scrolled(Entity entity, float amountX, float amountY);
|
||||
boolean scrolled(Entity entity, float amountX, float amountY);
|
||||
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ public class PanTool extends SimpleTool {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stageMouseScrolled(float amountX, float amountY) {
|
||||
|
||||
public boolean stageMouseScrolled(float amountX, float amountY) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -276,7 +276,7 @@ public class SelectionTool extends SimpleTool {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stageMouseScrolled(float amountX, float amountY) {
|
||||
public boolean stageMouseScrolled(float amountX, float amountY) {
|
||||
if (isItemDown) {
|
||||
for (Entity itemInstance : sandbox.getSelector().getCurrentSelection()) {
|
||||
transformComponent = ComponentRetriever.get(itemInstance, TransformComponent.class);
|
||||
@@ -293,6 +293,8 @@ public class SelectionTool extends SimpleTool {
|
||||
HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ITEM_DATA_UPDATED, itemInstance);
|
||||
}
|
||||
}
|
||||
|
||||
return isItemDown;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user