Artenus 2D Framework
Artenus Reference
Provides the user interface for horizontal menus that use slide action to navigate. It takes sprites as menu items and handles scaling and moving them as necessary. At any point you can get the currently focused item.
public final class SlideMenu
extends EntityCollection

Field Summary

Fields inherited from com.annahid.libs.artenus.entities.EntityCollection

Constructor Summary

Modifier and TypeConstructor and Description
public SlideMenu(Point2D center, float itemDistance, float height)
Creates a SlideMenu with the given information for the given scene.

Method Summary

Modifier and TypeMethod and Description
public final booleanadd(Entity entity)
Adds a menu item in the form of an entity.
public voidaddListener(SlideMenu.Listener listener)
Appoints a new event listener to listen to item selection events.
public final voidadvance(float elapsedTime)
Advances animations for the amount of time specified.
public voidclear()
Clears all menu items from this slide menu.
public final floatgetIndicatorAlpha(int index)
Provides information required to set up indicators.
public final intgetSelectedItem()
Gets the currently selected (focused) menu item.
public final booleanhandleTouch(TouchEvent event)
Handles a touch event for this SlideMenu.
public voidremoveListener(SlideMenu.Listener listener)
Removes an event listener currently assigned to this slide menu.
public voidsetPosition(Point2D position)
Does nothing.
public voidsetPosition(float x, float y)
Does nothing.
public final voidsetSelectedItem(int index)
Navigates to the menu item specified and focuses that item.
public voidsetTapFocus(float tapHeight)
Adjusts the tap focus for this SlideMenu.

Methods inherited from com.annahid.libs.artenus.entities.EntityCollection

Methods inherited from com.annahid.libs.artenus.data.ConcurrentCollection

Methods inherited from java.lang.Object

clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail

SlideMenu
public  SlideMenu(
    Point2D center,
    float itemDistance,
    float height
)
Creates a SlideMenu with the given information for the given scene.
Parameters:
centerThe center location of the menu
itemDistanceThe distance between items
heightThe height of the menu. This is used for touch handling

Method Detail

add
public final boolean add(
    Entity entity
)
Adds a menu item in the form of an entity.
Parameters:
entityThe menu item
Overrides:
addListener
public void addListener(
    SlideMenu.Listener listener
)
Appoints a new event listener to listen to item selection events.
Parameters:
listenerEvent listener to be added
advance
public final void advance(
    float elapsedTime
)
Advances animations for the amount of time specified.
Parameters:
elapsedTimeElapsed time since last frame
Overrides:
clear
public void clear()
Clears all menu items from this slide menu.
Overrides:
getIndicatorAlpha
public final float getIndicatorAlpha(
    int index
)
Provides information required to set up indicators. It provides transparency information for each indicator. An indicator has full transparency if the corresponding menu item is completely in view and starts to gradually decrease to zero when it goes out of focus.
Parameters:
indexMenu item index
Returns:
Indicator transparency
getSelectedItem
public final int getSelectedItem()
Gets the currently selected (focused) menu item.
Returns:
Item index
handleTouch
public final boolean handleTouch(
    TouchEvent event
)
Handles a touch event for this SlideMenu. It also determines whether and item has been tapped.
Parameters:
eventEvent information
Overrides:
removeListener
public void removeListener(
    SlideMenu.Listener listener
)
Removes an event listener currently assigned to this slide menu.
Parameters:
listenerEvent listener to be removed
setPosition
public void setPosition(
    Point2D position
)
Does nothing. Changing position is not supported by slide menu.
Parameters:
positionPosition (not used)
Overrides:
setPosition
public void setPosition(
    float x,
    float y
)
Does nothing. Changing position is not supported by slide menu.
Parameters:
xNot used
yNot used
Overrides:
setSelectedItem
public final void setSelectedItem(
    int index
)
Navigates to the menu item specified and focuses that item.
Parameters:
indexItem index
setTapFocus
public void setTapFocus(
    float tapHeight
)
Adjusts the tap focus for this SlideMenu. Tap focus is the vertical distance inside which a touch can be considered as a "tap" if there is not much horizontal motion.
Parameters:
tapHeightThe height of tap focus