Superclass for all dialogs. A dialog is a user interface component that pauses the normal
operation of a scene to do a short task, and resumes the scene upon the completion of the task.
Examples of dialogs are pop-up messages, waiting circles, and friend choosers. When a dialog is
displayed on a scene, the contents of the scene will still be visible behind the dialog, but
dimmer than the contents of the dialog. Input is also captured only by the dialog.
public abstract class Dialog extends Scene
Field Summary
Modifier and Type | Field and Description |
---|---|
public static final | RESULT_CANCEL Dialog result indicating that the dialog is cancelled. |
public static final | RESULT_NO Dialog result indicating a negative user response to the dialog. |
public static final | RESULT_NONE Dialog result indicating the dialog is still active. |
public static final | RESULT_OK Dialog result indicating that the dialog is dismissed. |
public static final | RESULT_YES Dialog result indicating a positive user response to the dialog. |
protected | result Holds the dialog result. |
Fields inherited from com.annahid.libs.artenus.core.Scene
Constructor Summary
Modifier and Type | Constructor and Description |
---|---|
public | Dialog(Scene parentScene) Creates a dialog that will be displayed above a given scene. |
Method Summary
Modifier and Type | Method and Description |
---|---|
public void | add(Entity entity) Adds an entity to the dialog. |
public final void | advance(float elapsedTime) Advances the animation for this scene. |
protected abstract void | advanceDialog(float elapsedTime) Advances animation for this dialog. |
public void | cancel() Cancels the dialog. |
protected abstract boolean | fadeIn(float elapsedTime) Advances animation for this dialog when it is fading in. |
protected abstract boolean | fadeOut(float elapsedTime) Advances animation for this dialog when it is fading out. |
public final int | getResult() Gets the result of the dialog. |
public boolean | isFull() Indicates whether the underlying scene is fully covered by this dialog. |
public boolean | onBackButton() Handles the back button for this dialog. |
public final void | show() Halts the underlying scene and displays the dialog on top of it. |
Methods inherited from com.annahid.libs.artenus.core.Scene
add
, advance
, getBackColor
, getDialog
, getPhysicsSimulator
, getStage
, getTouchMap
, halt
, handleInput
, handleTouch
, isHalted
, isLoaded
, onBackButton
, onDialogDismissed
, onHalted
, onLoaded
, onLocalLoad
, onUnhalted
, remove
, render
, setBackColor
, setBackColor
, unhalt
Methods inherited from java.lang.Object
clone
, equals
, finalize
, getClass
, hashCode
, notify
, notifyAll
, toString
, wait
, wait
, wait
Field Detail
RESULT_CANCEL |
---|
public static final RESULT_CANCEL Dialog result indicating that the dialog is cancelled. |
RESULT_NO |
---|
public static final RESULT_NO Dialog result indicating a negative user response to the dialog. |
RESULT_NONE |
---|
public static final RESULT_NONE Dialog result indicating the dialog is still active. |
RESULT_OK |
---|
public static final RESULT_OK Dialog result indicating that the dialog is dismissed. |
RESULT_YES |
---|
public static final RESULT_YES Dialog result indicating a positive user response to the dialog. |
result |
---|
protected result Holds the dialog result. Initially this field is RESULT_NONE. Setting a different
value for this field will cause the dialog to be dismissed. The scene can then check the
provided result and take an action accordingly. Some general results are included as
constants in this class. However, the developer can define their own result values, as long
as they are not equal to 0. |
Constructor Detail
Dialog | ||
---|---|---|
public Dialog( Scene parentScene )Creates a dialog that will be displayed above a given scene. Parameters:
|
Method Detail
add | ||
---|---|---|
public void add( Entity entity ) Adds an entity to the dialog. Dialog entities only belong to their parent dialog, and are
separate from the underlying scene. Parameters:
Overrides:
|
advance |
---|
public final void advance( float elapsedTime ) Advances the animation for this scene. Subclasses should always call this superclass method,
as it handles physics and animation. Overrides:
|
advanceDialog | ||
---|---|---|
protected abstract void advanceDialog( float elapsedTime ) Advances animation for this dialog. The advance method for Scene is
overridden and finalized by this class, and this method is a replacement. This method is only
called if the dialog is not fading in or out. Parameters:
|
cancel |
---|
public void cancel() Cancels the dialog. The default implementation of this method sets the result to
RESULT_CANCEL, and this is all this method does. But it can be overridden to change
this behavior. Pressing the back button invokes this method by default. |
fadeIn | ||
---|---|---|
protected abstract boolean fadeIn( float elapsedTime ) Advances animation for this dialog when it is fading in. The end of the fade-in process is
determined by the return value. Parameters:
Returns:
true if the dialog has completed fading in, false otherwise |
fadeOut | ||
---|---|---|
protected abstract boolean fadeOut( float elapsedTime ) Advances animation for this dialog when it is fading out. The end of the fade-out process is
determined by the return value. Parameters:
Returns:
true if the dialog has completed fading out, false otherwise |
getResult |
---|
public final int getResult() Gets the result of the dialog. If this method is called before the dialog is dismissed, it
returns RESULT_NONE .Returns:
Dialog result code |
isFull |
---|
public boolean isFull() Indicates whether the underlying scene is fully covered by this dialog. In this case the
underlying scene is not drawn for better performance. Returns:
true if the dialog fully covers the parent scene, false otherwise |
onBackButton |
---|
public boolean onBackButton() Handles the back button for this dialog. The default implementation cancels the dialog by
calling the cancel() method. Overrides:
Returns:
true if handled, false if passed |
show |
---|
public final void show() Halts the underlying scene and displays the dialog on top of it. |