public class SquidMouse
extends com.badlogic.gdx.InputAdapter
Modifier and Type | Field and Description |
---|---|
protected float |
cellHeight |
protected float |
cellWidth |
protected float |
gridHeight |
protected float |
gridWidth |
protected int |
offsetX |
protected int |
offsetY |
protected com.badlogic.gdx.InputProcessor |
processor |
Constructor and Description |
---|
SquidMouse(float cellWidth,
float cellHeight,
float gridWidth,
float gridHeight,
int offsetX,
int offsetY,
com.badlogic.gdx.InputProcessor processor)
Sets the size of the cell so that all mouse input can be evaluated as
relative to the grid.
|
SquidMouse(float cellWidth,
float cellHeight,
com.badlogic.gdx.InputProcessor processor)
Sets the size of the cell so that all mouse input can be evaluated as
relative to the grid.
|
Modifier and Type | Method and Description |
---|---|
float |
getCellHeight() |
float |
getCellWidth() |
float |
getGridHeight() |
float |
getGridWidth() |
int |
getOffsetX() |
int |
getOffsetY() |
com.badlogic.gdx.InputProcessor |
getProcessor()
Gets the InputProcessor this object uses to handle mouse input.
|
boolean |
mouseMoved(int screenX,
int screenY) |
boolean |
onGrid(int gridX,
int gridY)
Returns true if the provided screen coordinate is on the grid, ignoring the current offset.
|
void |
reinitialize(float cellWidth,
float cellHeight) |
void |
reinitialize(float cellWidth,
float cellHeight,
float gridWidth,
float gridHeight,
int offsetX,
int offsetY) |
boolean |
scrolled(float amountX,
float amountY) |
void |
setCellHeight(float cellHeight) |
void |
setCellWidth(float cellWidth) |
void |
setGridHeight(float gridHeight) |
void |
setGridWidth(float gridWidth) |
void |
setOffsetX(int offsetX) |
void |
setOffsetY(int offsetY) |
void |
setProcessor(com.badlogic.gdx.InputProcessor processor)
Sets the InputProcessor this object uses to handle mouse input.
|
boolean |
touchDown(int screenX,
int screenY,
int pointer,
int button) |
boolean |
touchDragged(int screenX,
int screenY,
int pointer) |
boolean |
touchUp(int screenX,
int screenY,
int pointer,
int button) |
int |
translateX(int screenX)
Translates the given screen pixel coordinate to the underlying grid coordinate, taking into account the related offset.
|
int |
translateY(int screenY)
Translates the given screen pixel coordinate to the underlying grid coordinate, taking into account the related offset.
|
protected float cellWidth
protected float cellHeight
protected float gridWidth
protected float gridHeight
protected int offsetX
protected int offsetY
protected com.badlogic.gdx.InputProcessor processor
public SquidMouse(float cellWidth, float cellHeight, com.badlogic.gdx.InputProcessor processor)
cellWidth
- the width of one cell in screen coordinates, usually pixelscellHeight
- the height of one cell in screen coordinates, usually pixelsprocessor
- an InputProcessor that implements some of touchUp(), touchDown(), touchDragged(), mouseMoved(), or scrolled().public SquidMouse(float cellWidth, float cellHeight, float gridWidth, float gridHeight, int offsetX, int offsetY, com.badlogic.gdx.InputProcessor processor)
cellWidth
- the width of one cell in screen coordinates, usually pixelscellHeight
- the height of one cell in screen coordinates, usually pixelsgridWidth
- in number of cells horizontally on the gridgridHeight
- in number of cells vertically on the gridoffsetX
- the horizontal offset in screen coordinates, usually pixelsoffsetY
- the vertical offset in screen coordinates, usually pixelsprocessor
- an InputProcessor that implements some of touchUp(), touchDown(), touchDragged(), mouseMoved(), or scrolled().public float getCellWidth()
public float getCellHeight()
public int getOffsetX()
public int getOffsetY()
public float getGridWidth()
public float getGridHeight()
public void setCellWidth(float cellWidth)
public void setCellHeight(float cellHeight)
public void setOffsetX(int offsetX)
public void setOffsetY(int offsetY)
public void setGridWidth(float gridWidth)
public void setGridHeight(float gridHeight)
public void reinitialize(float cellWidth, float cellHeight)
public void reinitialize(float cellWidth, float cellHeight, float gridWidth, float gridHeight, int offsetX, int offsetY)
public com.badlogic.gdx.InputProcessor getProcessor()
public void setProcessor(com.badlogic.gdx.InputProcessor processor)
processor
- an InputProcessor that implements some of touchUp(), touchDown(), touchDragged(), mouseMoved(), or scrolled().public int translateX(int screenX)
screenX
- a screen x position, usually in pixelspublic int translateY(int screenY)
screenY
- a screen y position, usually in pixelspublic boolean onGrid(int gridX, int gridY)
gridX
- x-coordinate measured in grid cells, not pixelsgridY
- y-coordinate measured in grid cells, not pixelspublic boolean touchDown(int screenX, int screenY, int pointer, int button)
touchDown
in interface com.badlogic.gdx.InputProcessor
touchDown
in class com.badlogic.gdx.InputAdapter
public boolean touchUp(int screenX, int screenY, int pointer, int button)
touchUp
in interface com.badlogic.gdx.InputProcessor
touchUp
in class com.badlogic.gdx.InputAdapter
public boolean touchDragged(int screenX, int screenY, int pointer)
touchDragged
in interface com.badlogic.gdx.InputProcessor
touchDragged
in class com.badlogic.gdx.InputAdapter
public boolean mouseMoved(int screenX, int screenY)
mouseMoved
in interface com.badlogic.gdx.InputProcessor
mouseMoved
in class com.badlogic.gdx.InputAdapter
public boolean scrolled(float amountX, float amountY)
scrolled
in interface com.badlogic.gdx.InputProcessor
scrolled
in class com.badlogic.gdx.InputAdapter
Copyright © Eben Howard 2012–2022. All rights reserved.