public class Cursor
extends java.lang.Object
Image
, the cursor can be rendered
immediately after the constructor call. It contains the following functionalities:
surface
: A cursor can contain many surfaces, but only the selected one is displayed.area
: Represents the area where the cursor can move on. Its location can not exit this area (
setArea(int, int, int, int)
).lock
: Allows to lock the cursor on the mouse (Mouse.setCenter(int, int)
,
Mouse.lock()
)sync
: true
if cursor is synchronized on the system mouse, false
not (
setSyncMode(boolean)
).sensibility
: If the mouse is not synchronized on the window mouse, it can be defined (
setSensibility(double, double)
).location
: The internal cursor position (setLocation(int, int)
).surfaceId
: This is the current cursor surface that can be displayed (
setSurfaceId(int)
).Mouse
,
Image
Constructor and Description |
---|
Cursor(com.b3dgs.lionengine.Mouse mouse,
int minX,
int minY,
int maxX,
int maxY,
com.b3dgs.lionengine.core.Media... medias)
Constructor.
|
Cursor(com.b3dgs.lionengine.Mouse mouse,
com.b3dgs.lionengine.Resolution resolution,
com.b3dgs.lionengine.core.Media... medias)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
getClick()
Return mouse click number.
|
int |
getLocationX()
Get horizontal location.
|
int |
getLocationY()
Get vertical location.
|
double |
getSensibilityHorizontal()
Get horizontal sensibility.
|
double |
getSensibilityVertical()
Get vertical sensibility.
|
int |
getSurfaceId()
Get the current surface id used for rendering.
|
boolean |
isSynchronized()
Check if the cursor is synchronized to the system mouse or not.
|
void |
render(com.b3dgs.lionengine.Graphic g)
Render cursor on screen at its current location.
|
void |
setArea(int minX,
int minY,
int maxX,
int maxY)
Allows cursor to move only inside the specified area.
|
void |
setLocation(int x,
int y)
Set cursor location.
|
void |
setLockMouse(boolean lock)
Set the mouse lock.
|
void |
setRenderingOffset(int ox,
int oy)
Set the rendering offsets value (allows to apply an offset depending of the cursor surface).
|
void |
setSensibility(double sh,
double sv)
Set cursor sensibility (move speed).
|
void |
setSurfaceId(int surfaceId)
Set the surface id to render with
render(Graphic) . |
void |
setSyncMode(boolean sync)
Set the cursor synchronization to the mouse.
|
void |
update(double extrp)
Update cursor position depending of mouse movement.
|
public Cursor(com.b3dgs.lionengine.Mouse mouse, com.b3dgs.lionengine.Resolution resolution, com.b3dgs.lionengine.core.Media... medias)
mouse
- The mouse reference (must not be null
).resolution
- The resolution used to know the screen limits.medias
- The cursor media list (containing the different cursor surfaces path).public Cursor(com.b3dgs.lionengine.Mouse mouse, int minX, int minY, int maxX, int maxY, com.b3dgs.lionengine.core.Media... medias)
mouse
- The mouse reference (must not be null
).minX
- The minimal x location on screen.minY
- The minimal y location on screen.maxX
- The maximal x location on screen.maxY
- The maximal y location on screen.medias
- The cursor media list (containing the different cursor surfaces path).public void update(double extrp)
extrp
- The extrapolation value.public void render(com.b3dgs.lionengine.Graphic g)
g
- The graphic output.public void setLockMouse(boolean lock)
lock
- Lock state.public void setSyncMode(boolean sync)
sync
- The sync mode (true
= sync to window mouse; false
= internal movement).public void setSensibility(double sh, double sv)
sh
- The horizontal sensibility (>= 0.0).sv
- The vertical sensibility (>= 0.0).public void setLocation(int x, int y)
x
- The horizontal location.y
- The vertical location.public void setSurfaceId(int surfaceId)
render(Graphic)
.surfaceId
- The surface id number (start at 0 which is default value).public void setRenderingOffset(int ox, int oy)
ox
- The horizontal offset.oy
- The vertical offset.public void setArea(int minX, int minY, int maxX, int maxY)
minX
- The minimal x.minY
- The minimal y.maxX
- The maximal x.maxY
- The maximal y.public int getClick()
public int getSurfaceId()
public int getLocationX()
public int getLocationY()
public double getSensibilityHorizontal()
public double getSensibilityVertical()
public boolean isSynchronized()
true
= sync to the system mouse; false
= internal movement.