public class Cursor extends Object implements Resource, Shape, Updatable, Renderable
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)
).sync
: true
if cursor is synchronized on the system pointer, false
not (
setSyncMode(boolean)
).sensibility
: If the cursor is not synchronized on the system pointer, it can be defined (
setSensibility(double, double)
).grid
: Represents the map grid.location
: The internal cursor position (setLocation(int, int)
).surfaceId
: This is the current cursor surface that can be displayed (setSurfaceId(int)
).Usage example:
Cursor()
.addImage(int, Media)
.load()
.setInputDevice(InputDevicePointer)
.setSurfaceId(int)
.setArea(int, int, int, int)
.InputDevicePointer
,
Image
Constructor and Description |
---|
Cursor()
Create a cursor.
|
Modifier and Type | Method and Description |
---|---|
void |
addImage(int id,
Media media)
Add a cursor image.
|
void |
dispose() |
int |
getClick()
Get the click number.
|
int |
getHeight() |
double |
getScreenX()
Get the current horizontal location on screen.
|
double |
getScreenY()
Get the current vertical location on screen.
|
double |
getSensibilityHorizontal()
Get horizontal sensibility.
|
double |
getSensibilityVertical()
Get vertical sensibility.
|
Integer |
getSurfaceId()
Get the current surface id used for rendering.
|
int |
getWidth() |
double |
getX() |
double |
getY() |
boolean |
hasClicked(int click)
Check if click is pressed.
|
boolean |
hasClickedOnce(int click)
Check if click is pressed once only (ignore 'still clicked').
|
boolean |
isLoaded() |
boolean |
isSynchronized()
Check if the cursor is synchronized to the system pointer or not.
|
void |
load() |
void |
render(Graphic g) |
void |
setArea(int minX,
int minY,
int maxX,
int maxY)
Allows cursor to move only inside the specified area.
|
void |
setGrid(int width,
int height)
Set the grid size.
|
void |
setInputDevice(InputDevicePointer pointer)
Set the input device pointer to use.
|
void |
setLocation(int x,
int y)
Set cursor location.
|
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 pointer.
|
void |
setViewer(Viewer viewer)
Set the viewer reference.
|
void |
setVisible(boolean visible)
Set the visibility.
|
void |
update(double extrp) |
public void addImage(int id, Media media)
load()
will be necessary.id
- The cursor id.media
- The cursor media.LionEngineException
- If invalid media.public void setInputDevice(InputDevicePointer pointer)
pointer
- The pointer reference (must not be null
).LionEngineException
- If invalid pointer.public void setViewer(Viewer viewer)
viewer
- The viewer reference.LionEngineException
- If invalid viewer.public void setSyncMode(boolean sync)
sync
- The sync mode (true
= sync to system pointer; false
= internal movement).public void setSensibility(double sh, double sv)
sh
- The horizontal sensibility (superior or equal to 0.0).sv
- The vertical sensibility (superior or equal to 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 (must be strictly positive).LionEngineException
- If invalid id value or not found.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 void setGrid(int width, int height)
width
- The horizontal grid (strictly positive).height
- The vertical grid (strictly positive).LionEngineException
- If grid is not strictly positive.public void setVisible(boolean visible)
visible
- true
to show, false
to hide.public int getClick()
public boolean hasClicked(int click)
click
- The click to check.public boolean hasClickedOnce(int click)
click
- The click to check.public Integer getSurfaceId()
public double getSensibilityHorizontal()
public double getSensibilityVertical()
public double getScreenX()
public double getScreenY()
public boolean isSynchronized()
true
= sync to the system pointer; false
= internal movement.public void render(Graphic g)
render
in interface Renderable
public double getX()
getX
in interface Localizable
public double getY()
getY
in interface Localizable
Copyright © 2017 Byron 3D Games Studio. All rights reserved.