Package games.stendhal.client
Class GameScreenSpriteHelper
java.lang.Object
games.stendhal.client.GameScreenSpriteHelper
Some GameScreen methods that can be accessed by individual sprites.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intconvertWorldToPixelUnits(double w) Convert a world unit value to pixel units.static intconvertWorldXToScaledScreen(double x) Convert a world x coordinate to raw (native resolution) screen x coordinate.static intconvertWorldYToScaledScreen(double y) Convert a world y coordinate to raw (native resolution) screen y coordinate.static intfindFreeTextBoxPosition(Sprite sprite, int x, int sy) Adjust the position of boxes placed at the same point to make it clear for the player there are more than one.static GameScreenSpriteHelperget()Retrieves the singleton instance.static intGets the view X screen coordinate.static intGets the view Y screen coordinate.static intkeepSpriteOnMapX(Sprite sprite, int sx) Try to keep a sprite on the map.static intkeepSpriteOnMapY(Sprite sprite, int sy) Try to keep a sprite on the map.
-
Method Details
-
get
Retrieves the singleton instance. -
getScreenViewX
public static int getScreenViewX()Gets the view X screen coordinate.- Returns:
- The X coordinate of the left side.
-
getScreenViewY
public static int getScreenViewY()Gets the view Y screen coordinate.- Returns:
- The Y coordinate of the left side.
-
convertWorldToPixelUnits
public static int convertWorldToPixelUnits(double w) Convert a world unit value to pixel units.- Parameters:
w- World value.- Returns:
- A screen value (in pixels).
-
convertWorldXToScaledScreen
public static int convertWorldXToScaledScreen(double x) Convert a world x coordinate to raw (native resolution) screen x coordinate.- Parameters:
x- World X coordinate.- Returns:
- Pixel X coordinate on the screen.
-
convertWorldYToScaledScreen
public static int convertWorldYToScaledScreen(double y) Convert a world y coordinate to raw (native resolution) screen y coordinate.- Parameters:
y- World Y coordinate.- Returns:
- Pixel Y coordinate on the screen.
-
keepSpriteOnMapX
Try to keep a sprite on the map. Adjust the X coordinate.- Parameters:
sprite- Sprite to keep on the map.sx- Suggested X coordinate on screen.- Returns:
- New X coordinate.
-
keepSpriteOnMapY
Try to keep a sprite on the map. Adjust the Y coordinate.- Parameters:
sprite- Sprite to keep on the map.sy- Suggested Y coordinate on screen.- Returns:
- New Y coordinate.
-
findFreeTextBoxPosition
Adjust the position of boxes placed at the same point to make it clear for the player there are more than one.- Parameters:
sprite-x-sy-
-