Class TrainingDummy2DView
java.lang.Object
games.stendhal.client.gui.j2d.entity.Entity2DView<T>
games.stendhal.client.gui.j2d.entity.TrainingDummy2DView
- All Implemented Interfaces:
Inspectable,EntityView<NPC>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intThe drawn height.Map of named sprites.protected intfor adjusting entity hp bar & title vertical positionprotected intThe drawn width.Fields inherited from class games.stendhal.client.gui.j2d.entity.Entity2DView
animatedChanged, entity, representationChanged, visibilityChanged -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected SpriteDraws a shadow under image if shadows are enabled in the client.protected voidbuildActions(List<String> list) Build a list of entity specific actions.protected voidbuildRepresentation(NPC entity) Build the visual representation of this entity.protected voidbuildSprites(Map<Object, Sprite> map, Sprite tiles, int width, int height) Populate keyed state sprites.protected voidbuildSprites(NPC entity, Map<Object, Sprite> map) Populate keyed state sprites.protected SpritecreateWalkSprite(Sprite tiles, int y, int width, int height) Extract a walking animation for a specific row.protected voiddraw(Graphics2D g2d, int x, int y, int width, int height) Draw the entity.protected voiddrawHPbar(Graphics2D g2d, int x, int y, int width) Draw the entity HP bar.protected voiddrawStatusBar(Graphics2D g2d, int x, int y, int width) Draw the entity status bar.protected voiddrawTitle(Graphics2D g2d, int x, int y, int width) Draw the entity title.protected voiddrawTop(Graphics2D g2d, int x, int y, int width, int height) Draw the top layer parts of an entity.protected SpriteGet the full directional animation tile set for this entity.Gets the mouse cursor image to use for this entity.intGet the height.protected SpriteGet a keyed state sprite.protected DirectionGet the current model state.protected intGet the number of tiles in the X axis of the base sprite.protected intGet the number of tiles in the Y axis of the base sprite.protected intGet the entity's visibility.intgetWidth()Get the width.intDetermines on top of which other entities this entity should be drawn.voidinitialize(NPC entity) protected booleanDetermine if this view is currently animatable.protected booleanDetermine is the user can see this entity while in ghostmode.voidonAction()Perform the default action.voidonAction(ActionType at) Perform an action.protected voidproceedChangedState(NPC entity) Update sprite state of the entity.protected voidreorderActions(List<String> list) Places "attack" as first option in action context menu.voidprotected voidupdate()Handle updates.Methods inherited from class games.stendhal.client.gui.j2d.entity.Entity2DView
applyChanges, attachSprite, calculateOffset, detachSprite, draw, drawEntity, drawTop, getActions, getArea, getClassResourcePath, getComposite, getDrawingArea, getEntity, getSprite, getX, getXOffset, getY, getYOffset, isContained, isInteractive, isMovable, isReleased, onHarmlessAction, release, setContained, setInspector, setSprite, translate
-
Field Details
-
titleDrawYOffset
protected int titleDrawYOffsetfor adjusting entity hp bar & title vertical position -
height
protected int heightThe drawn height. -
width
protected int widthThe drawn width. -
sprites
Map of named sprites.
-
-
Constructor Details
-
TrainingDummy2DView
public TrainingDummy2DView()
-
-
Method Details
-
reorderActions
Places "attack" as first option in action context menu.- Overrides:
reorderActionsin classEntity2DView<NPC>- Parameters:
list- The list to reorder.
-
onAction
public void onAction()Perform the default action.- Specified by:
onActionin interfaceEntityView<NPC>
-
getCursor
Gets the mouse cursor image to use for this entity.- Specified by:
getCursorin interfaceEntityView<NPC>- Returns:
- StendhalCursor
-
initialize
- Specified by:
initializein interfaceEntityView<T extends NPC>
-
getAnimationSprite
Get the full directional animation tile set for this entity.- Returns:
- A tile sprite containing all animation images.
-
buildActions
Build a list of entity specific actions. NOTE: The first entry should be the default.- Parameters:
list- The list to populate.
-
update
protected void update()Handle updates. -
onAction
Perform an action.- Specified by:
onActionin interfaceEntityView<T extends NPC>- Parameters:
at- The action.
-
buildSprites
Populate keyed state sprites.- Parameters:
map- The map to populate.tiles- The master sprite.width- The tile width (in pixels).height- The tile height (in pixels).
-
createWalkSprite
Extract a walking animation for a specific row. The source sprite contains 3 animation tiles, but this is converted to 4 frames.- Parameters:
tiles- The tile image.y- The base Y coordinate.width- The frame width.height- The frame height.- Returns:
- A sprite.
-
drawHPbar
Draw the entity HP bar.- Parameters:
g2d- The graphics context.x- The drawn X coordinate.y- The drawn Y coordinate.width- The drawn width.
-
drawStatusBar
Draw the entity status bar. The status bar show the title and HP bar.- Parameters:
g2d- The graphics context.x- The drawn X coordinate.y- The drawn Y coordinate.width- The drawn width.
-
drawTitle
Draw the entity title.- Parameters:
g2d- The graphics context.x- The drawn X coordinate.y- The drawn Y coordinate.width- The drawn width.
-
addShadow
Draws a shadow under image if shadows are enabled in the client.- Parameters:
sprite- The sprite to manipulate.- Returns:
- Sprite
-
getTilesX
protected int getTilesX()Get the number of tiles in the X axis of the base sprite.- Returns:
- The number of tiles.
-
getTilesY
protected int getTilesY()Get the number of tiles in the Y axis of the base sprite.- Returns:
- The number of tiles.
-
isVisibleGhost
protected boolean isVisibleGhost()Determine is the user can see this entity while in ghostmode.- Returns:
trueif the client user can see this entity while in ghostmode.
-
buildSprites
Populate keyed state sprites.- Parameters:
entity- the entity to build sprites formap- The map to populate.
-
draw
Draw the entity.- Overrides:
drawin classEntity2DView<T extends RPEntity>- Parameters:
g2d- The graphics context.x- The drawn X coordinate.y- The drawn Y coordinate.width- The drawn entity width.height- The drawn entity height.
-
drawTop
Draw the top layer parts of an entity. This will be on down after all other game layers are rendered.- Overrides:
drawTopin classEntity2DView<T extends RPEntity>- Parameters:
g2d- The graphics context.x- The drawn X coordinate.y- The drawn Y coordinate.width- The drawn entity width.height- The drawn entity height.
-
getHeight
public int getHeight()Get the height.- Overrides:
getHeightin classEntity2DView<T extends RPEntity>- Returns:
- The height (in pixels).
-
getVisibility
protected int getVisibility()Get the entity's visibility.- Overrides:
getVisibilityin classEntity2DView<T extends RPEntity>- Returns:
- The visibility value (0-100).
-
getWidth
public int getWidth()Get the width.- Overrides:
getWidthin classEntity2DView<T extends RPEntity>- Returns:
- The width (in pixels).
-
getZIndex
public int getZIndex()Determines on top of which other entities this entity should be drawn. Entities with a high Z index will be drawn on top of ones with a lower Z index. Also, players can only interact with the topmost entity.- Specified by:
getZIndexin interfaceEntityView<T extends RPEntity>- Overrides:
getZIndexin classEntity2DView<T extends RPEntity>- Returns:
- The drawing index.
-
setVisibleScreenArea
- Specified by:
setVisibleScreenAreain interfaceEntityView<T extends RPEntity>- Overrides:
setVisibleScreenAreain classEntity2DView<T extends RPEntity>
-
getState
Get the current model state.- Parameters:
entity-- Returns:
- The model state.
-
isAnimating
protected boolean isAnimating()Determine if this view is currently animatable.- Overrides:
isAnimatingin classEntity2DView<T extends ActiveEntity>- Returns:
trueif animating enabled.
-
getSprite
Get a keyed state sprite.- Parameters:
state- The state.- Returns:
- The appropriate sprite for the given state.
-
buildRepresentation
Build the visual representation of this entity. This builds all the animation sprites and sets the default frame.- Overrides:
buildRepresentationin classEntity2DView<T extends IEntity>- Parameters:
entity- the eEntity to build the representation for
-
proceedChangedState
Update sprite state of the entity.- Parameters:
entity-
-