com.b3dgs.lionengine.game.strategy
Class StrategyCursor

java.lang.Object
  extended by com.b3dgs.lionengine.game.strategy.StrategyCursor
All Implemented Interfaces:
Cursor

public class StrategyCursor
extends java.lang.Object
implements Cursor

This class can be used to handle easely a strategy cursor, designed to select and give order to any kind of entry. The cursor is asynchronous compared to the mouse window.

See Also:
AbstractEntry

Constructor Summary
StrategyCursor(Screen screen, java.lang.String cursor, TileBasedMap<?> map)
          Create a new strategy cursor.
 
Method Summary
 boolean canClick(AbstractControlPanel<?,?,?> panel)
          Check if cursor can click for a selection (cursor outside panel).
 void fixBetween(int minX, int minY, int maxX, int maxY)
          Allow cursor to move only in the specified area.
 int getClick()
          Return mouse click number.
 java.awt.geom.Rectangle2D getGrid(int size)
          Get a rectangle describing a grid (placed on the cursor, depending of map tile size).
 int getHorizontalMapTile()
          Get the horizontal tile pointed by the cursor.
 float getHorizontalSensibility()
          Get horizontal sensibility.
 int getMoveX()
          Get cursor horizontal move.
 int getMoveY()
          Get cursor vertical move.
 int getScreenX()
          Get cursor location x on screen (not synced to any camera).
 int getScreenY()
          Get cursor location y on screen (not synced to any camera).
 int getVerticalMapTile()
          Get the vertical tile pointed by the cursor.
 float getVerticalSensibility()
          Get vertical sensibility.
 int getX()
          Get cursor location x on map (synced to camera).
 int getX(int sx, int sy)
          Get real location x (from map referential), avoiding control panel.
 int getY()
          Get cursor location y on map (synced to camera).
 int getY(int sx, int sy)
          Get real location y (from map referential), avoiding control panel (see checkCursor).
 void lockMouse(boolean lock)
          Lock mouse state.
 void place(int x, int y)
          Set cursor location.
 void render(java.awt.Graphics2D g)
          Render cursor on screen.
 void setLimits(java.awt.geom.Rectangle2D clickableArea)
          Set clickable area.
 void setSensibility(int sh, int sv)
          Set cursor sensibility (move speed).
 void update(Mouse mouse, boolean async, float extrp)
          Deprecated. Call update(Mouse mouse, StrategyCamera camera, float extrp) instead.
 void update(Mouse mouse, boolean async, StrategyCamera camera, float extrp)
          This update function is preferable to the other one, as it allows to interact with objects in the map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StrategyCursor

public StrategyCursor(Screen screen,
                      java.lang.String cursor,
                      TileBasedMap<?> map)
Create a new strategy cursor.

Parameters:
screen - screen reference.
cursor - cursor image path.
map - map reference.
Method Detail

setLimits

public void setLimits(java.awt.geom.Rectangle2D clickableArea)
Set clickable area. Mainly used for a selection.

Parameters:
clickableArea - clickable area.
See Also:
AbstractControlPanel

canClick

public boolean canClick(AbstractControlPanel<?,?,?> panel)
Check if cursor can click for a selection (cursor outside panel).

Parameters:
panel - panel reference.
Returns:
true if can click, false else.

update

@Deprecated
public void update(Mouse mouse,
                              boolean async,
                              float extrp)
Deprecated. Call update(Mouse mouse, StrategyCamera camera, float extrp) instead.

Description copied from interface: Cursor
Update cursor position depending of mouse movement.

Specified by:
update in interface Cursor
Parameters:
mouse - mouse reference.
extrp - extrapolation value.

update

public void update(Mouse mouse,
                   boolean async,
                   StrategyCamera camera,
                   float extrp)
This update function is preferable to the other one, as it allows to interact with objects in the map.

Parameters:
mouse - mouse reference.
camera - camera reference.
extrp - extrapolation value.

render

public void render(java.awt.Graphics2D g)
Description copied from interface: Cursor
Render cursor on screen.

Specified by:
render in interface Cursor
Parameters:
g - graphic output.

getGrid

public java.awt.geom.Rectangle2D getGrid(int size)
Get a rectangle describing a grid (placed on the cursor, depending of map tile size).

Parameters:
size - size (in tile square).
Returns:
rectangle reference (can be used with g.draw() to see the result).

setSensibility

public void setSensibility(int sh,
                           int sv)
Description copied from interface: Cursor
Set cursor sensibility (move speed).

Specified by:
setSensibility in interface Cursor
Parameters:
sh - horizontal speed.
sv - vertical speed.

getClick

public int getClick()
Description copied from interface: Cursor
Return mouse click number.

Specified by:
getClick in interface Cursor
Returns:
mouse click number.

place

public void place(int x,
                  int y)
Description copied from interface: Cursor
Set cursor location.

Specified by:
place in interface Cursor
Parameters:
x - horizontal location.
y - vertical location.

fixBetween

public void fixBetween(int minX,
                       int minY,
                       int maxX,
                       int maxY)
Description copied from interface: Cursor
Allow cursor to move only in the specified area.

Specified by:
fixBetween in interface Cursor
Parameters:
minX - minimal x.
minY - minimal y.
maxX - maximal x.
maxY - maximal y.

getX

public int getX()
Get cursor location x on map (synced to camera).

Specified by:
getX in interface Cursor
Returns:
map location x.

getY

public int getY()
Get cursor location y on map (synced to camera).

Specified by:
getY in interface Cursor
Returns:
map location y.

getScreenX

public int getScreenX()
Get cursor location x on screen (not synced to any camera).

Returns:
cursor location x on screen.

getScreenY

public int getScreenY()
Get cursor location y on screen (not synced to any camera).

Returns:
cursor location y on screen.

getX

public int getX(int sx,
                int sy)
Get real location x (from map referential), avoiding control panel. This function is mainly used for a selection.

Parameters:
sx - starting selection location x.
sy - starting selection location y.
Returns:
valid location x outside panel.
See Also:
AbstractControlPanel

getY

public int getY(int sx,
                int sy)
Get real location y (from map referential), avoiding control panel (see checkCursor). This function is mainly used for a selection.

Parameters:
sx - starting selection location x.
sy - starting selection location y.
Returns:
valid location y outside panel.
See Also:
AbstractControlPanel

getHorizontalMapTile

public int getHorizontalMapTile()
Get the horizontal tile pointed by the cursor.

Returns:
horizontal tile pointed by the cursor.

getVerticalMapTile

public int getVerticalMapTile()
Get the vertical tile pointed by the cursor.

Returns:
vertical tile pointed by the cursor.

getHorizontalSensibility

public float getHorizontalSensibility()
Description copied from interface: Cursor
Get horizontal sensibility.

Specified by:
getHorizontalSensibility in interface Cursor
Returns:
horizontal sensibility.

getVerticalSensibility

public float getVerticalSensibility()
Description copied from interface: Cursor
Get vertical sensibility.

Specified by:
getVerticalSensibility in interface Cursor
Returns:
vertical sensibility.

getMoveX

public int getMoveX()
Get cursor horizontal move.

Returns:
horizontal move.

getMoveY

public int getMoveY()
Get cursor vertical move.

Returns:
vertical move.

lockMouse

public void lockMouse(boolean lock)
Description copied from interface: Cursor
Lock mouse state.

Specified by:
lockMouse in interface Cursor
Parameters:
lock - true to lock mouse.