apes
Class MenuItem

java.lang.Object
  extended by apes.MenuItem

public class MenuItem
extends java.lang.Object

A MenuItem represents one part of a Menu. It contains an Image that is shown to represent it when the menu it belongs to is shown. It also contains a MenuAction which contains instruction on how to act if isMouseOverItem returns true and the user pressed a mouse button.

See Also:
Menu, MenuAction

Constructor Summary
MenuItem(org.newdawn.slick.Image img, float xPos, float yPos, float offset, MenuAction action)
          constructs a new MenuItem.
 
Method Summary
 void applyMouseInput(float x, float y, boolean mouseButtonDown, int i, org.newdawn.slick.GameContainer gc, org.newdawn.slick.state.StateBasedGame sbg)
          Checks weather or not this MenuItem is affected by the current condition of the mouse.
 org.newdawn.slick.Image getImg()
          returns the image represented by this item.
 org.newdawn.slick.geom.Polygon getPolygon()
          returns the polygon surrounding the image representing this item.
 void render()
          draw the image representing this menuitem with the set x/y position and scale.
 void setImg(org.newdawn.slick.Image img)
          sets the image to represent this item.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MenuItem

public MenuItem(org.newdawn.slick.Image img,
                float xPos,
                float yPos,
                float offset,
                MenuAction action)
constructs a new MenuItem.

Parameters:
img - the image, which is shown to represent this MenuItem
xPos - the top left x position of this image
yPos - top left y position of this image
action - the action to execute
offset - the offset, the polygon around this item may have
Method Detail

applyMouseInput

public void applyMouseInput(float x,
                            float y,
                            boolean mouseButtonDown,
                            int i,
                            org.newdawn.slick.GameContainer gc,
                            org.newdawn.slick.state.StateBasedGame sbg)
                     throws org.newdawn.slick.SlickException
Checks weather or not this MenuItem is affected by the current condition of the mouse. If the mouse is positioned on it, the image representing it will slowly grow to indicate that this item is currently selected. If the mouse is not positioned on it and it is still enlarged, it will shrink. If the mouse is positioned on it, its MenuAction will be executed.

Parameters:
x - position of mouse on x axis
y - position of mouse on y axis
mouseButtonDown - is mouse klicked?
i - delta value
gc - gamecontainer
sbg - statebased game
Throws:
org.newdawn.slick.SlickException

render

public void render()
draw the image representing this menuitem with the set x/y position and scale.


getImg

public org.newdawn.slick.Image getImg()
returns the image represented by this item.

Returns:

setImg

public void setImg(org.newdawn.slick.Image img)
sets the image to represent this item.

Parameters:
img -

getPolygon

public org.newdawn.slick.geom.Polygon getPolygon()
returns the polygon surrounding the image representing this item.

Returns: