Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## superwaba.ext.xplat.game
Class AnimatedButton

    java.lang.Object
      |
      +--waba.ui.Control
            |
            +--superwaba.ext.xplat.game.Animation
                  |
                  +--superwaba.ext.xplat.game.AnimatedButton

public class AnimatedButton
extends Animation

The animated button control.

     This control displays an animated button which can take 'S' different states
     and each state is fades in or out in 'F' frames. 'S' and 'F' represent the
     two first constructor arguments. The frames of this special animation have to be
     ordered to be supported by this class. The states are numbered from 0 to 'S'-1
     and the frames order is the following depending on the layoutType value:

     FADE_OUT_LAYOUT    :  S0F0,S0F1,S0F2,S1F0,S1F1,S1F2,S2F0,S2F1,S2F2

     FADE_IN_LAYOUT     :  S0F2,S0F1,S0F0,S1F2,S1F1,S1F0,S2F2,S2F1,S2F0

     FADE_INOUT_LAYOUT  :  S0F0,S0F1,S1F1,S1F0,S1F1,S2F1,S2F0,S2F1,S0F1

     where S stands for state, F for frame and where S0F0, S1F0 and S2F0
     are the full states and the others are transition frames.
     Open the 'onOff.bmp' in the PingGame sample and you will understand ;-)

Field Summary
`static int` | `FADE_IN_LAYOUT` Frames fading in mode.
`static int` | `FADE_OUT_IN_LAYOUT` Frames fading out then fading in mode.
`static int` | `FADE_OUT_LAYOUT` Defines the frames animation order.
`protected int` | `fadeInState`
`protected int` | `framesPerState`
`protected int` | `layoutType`
`protected int` | `maxStates`
`protected int` | `state` current animated button state
`protected int[]` | `statesIndexes`

Fields inherited from class superwaba.ext.xplat.game.Animation
`curFrame, drawOp, framePeriod, framesBuffer, isPaused, isPlaying, maxFrames, transColor`

Fields inherited from class waba.ui.Control
`AFTER, appId, asContainer, asWindow, backColor, backDis, BEFORE, BOTTOM, CENTER, enabled, FILL, FIT, fm, fmH, focusLess, font, foreColor, foreDis, height, LEFT, parent, PREFERRED, RANGE, RIGHT, SAME, TOP, visible, width, x, x2, y, y2`

Constructor Summary
`AnimatedButton(int states, int framesPerState, int layoutType, Color transColor, int framePeriod)` Animated button constructor.

Method Summary
`int` | `getState()` Get the animated button state.
`protected void` | `inc(boolean up)` Increase/decrease the animated button state.
`void` | `onEvent(Event event)` Animated button event handler.
`void` | `setState(int state)` Set the animated button state.

Methods inherited from class superwaba.ext.xplat.game.Animation
`addFrame, addMultiFrames, addMultiFrames, drawFrame, getPreferredHeight, getPreferredWidth, notifyEachFrame, onPaint, pause, renew, resume, setFrames, size, splitImage, start, start, start, stop`

Methods inherited from class waba.ui.Control
`addTimer, contains, createGraphics, getAbsoluteRect, getBackColor, getFont, getFontMetrics, getForeColor, getNext, getParent, getParentWindow, getPos, getRect, getSize, isDisplayed, isEnabled, isVisible, onBoundsChanged, onColorsChanged, onFontChanged, onWindowPaintFinished, postEvent, removeTimer, repaint, repaintNow, requestFocus, setBackColor, setBackForeColors, setEnabled, setFocusLess, setFont, setForeColor, setRect, setRect, setRect, setVisible`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, toString, wait, wait`

Field Detail

### FADE_OUT_LAYOUT

    public static final int FADE_OUT_LAYOUT

  Defines the frames animation order. In the case of a "S" states button of "F" frames per state, FADE_OUT_LAYOUT means that the frames are a "S" set of "F" frames that are fading out the state, that means the first frame of of each set is the full state image. In the FADE_IN_LAYOUT layout, it's the opposite, namely the last frame of each set represents the state ending position. Finaly the FADE_OUT_IN_LAYOUT is a mix of the two others, because inter-frames represent successively fading out from one state to fading in to next state.
  See Also:
    `game tutorial for samples.`

### FADE_IN_LAYOUT

    public static final int FADE_IN_LAYOUT

  Frames fading in mode. @see FADE_OUT_LAYOUT

### FADE_OUT_IN_LAYOUT

    public static final int FADE_OUT_IN_LAYOUT

  Frames fading out then fading in mode. @see FADE_OUT_LAYOUT

### state

    protected int state

  current animated button state

### layoutType

    protected int layoutType

### fadeInState

    protected int fadeInState

### framesPerState

    protected int framesPerState

### maxStates

    protected int maxStates

### statesIndexes

    protected int[] statesIndexes

Constructor Detail

### AnimatedButton

    public AnimatedButton(int states,
                          int framesPerState,
                          int layoutType,
                          Color transColor,
                          int framePeriod)

  Animated button constructor.
  Parameters:
    `states` - number of states of the button.
    `framesPerState` - number of frames for each state.
    `layoutType` - FADE_OUT_LAYOUT or FADE_IN_LAYOUT.
    `transColor` - the transparency color
    `framePeriod` - delay in millisecconds between two frames
  See Also:
    `FADE_OUT_LAYOUT`, `FADE_IN_LAYOUT`

Method Detail

### setState

    public void setState(int state)

  Set the animated button state.
  Parameters:
    `state` - value between 0 and states-1

### getState

    public int getState()

  Get the animated button state.
  Returns:
    value between 0 and states-1

### onEvent

    public void onEvent(Event event)

  Animated button event handler.
  Overrides:
    onEvent in class Control
  Parameters:
    `event` -

### inc

    protected void inc(boolean up)

  Increase/decrease the animated button state.
  Parameters:
    `up` - boolean with a true value to increase the value, decrease otherwise

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD