PowerQuest 0.20.6
Loading...
Searching...
No Matches
IImage Interface Reference

Detailed Description

Gui Image - Gui Images are a bit like props (only not clickable). Note, that by default gui Image controls may not have a "Power Sprite Animation" component, and this needs to be added for them to play animations. Image.LockedIndicator.Anim = "Unlocked"; Image.LockedIndicator.PlayAnimationBG("Sparkle");

Inherits IGuiControl.

Properties

new string Anim [get, set]
 Gets/Sets the Sprite (or animation) for the gui image.
 
bool Animating [get]
 Whether an animation triggered by PlayAnimation() is currently playing. Note- this does not include animations set using the Anim property.
 
float Alpha [get, set]
 Gets/Sets the transparency of the sprite. (0.0f being fully transparent, 1.0f being fully opaque.)
 
- Properties inherited from IGuiControl
MonoBehaviour Instance [get]
 Access to the actual game object component in the scene. Note that controls themselves can be cast to their component type if known.
 
bool Visible [get, set]
 Sets the control visible invisible the control.
 
Vector2 Position [get, set]
 Gets/Sets the position of the control. Note that this will be overridden if using AlignTo or FitTo component.
 
bool Focused [get]
 Gets/Sets whether this control is focused (ie: the mouse is hovering over it, or it's selected with keyboard)
 
bool HasKeyboardFocus [get, set]
 Gets/Sets whether this control has the current keyboard focus (can also be used for specifying which control has 'controller' focus)
 
string Description [get, set]
 Note: Not all gui controls implement these. But most do, so adding them here for convenience.
 
string Cursor [get, set]
 Gets or sets the cursor to show when hovering over the control (if it's clickable). If empty, default active cursor will be used.
 
string Text [get, set]
 Gets/Sets the text of the control (if it has any)
 
Color Color [get, set]
 Gets/Sets the color for the control (if applicable)
 

Public Member Functions

void PauseAnimation ()
 Pauses the currently playing animation. Only works for animations played with PlayAnimationBG()
 
void ResumeAnimation ()
 Resumes playing the current animation after PauseAnimation() was called.
 
void StopAnimation ()
 Stops the current animation- returns to Idle animation. Only works for animations played with PlayAnimationBG()
 
Coroutine PlayAnimation (string animName)
 Plays an animation on the control. Will block the script until complete.
 
void PlayAnimationBG (string animName)
 Play an animation on the control without halting the script. Will return to idle after animation ends, unless pauseAtEnd is true.
 
void AddAnimationTrigger (string triggerName, bool removeAfterTriggering, System.Action action)
 Adds a function to be called on an animation event here. Eg: to play a sound or effect on an animation tag.
 
void RemoveAnimationTrigger (string triggerName)
 Removes an existing animation trigger.
 
Coroutine WaitForAnimTrigger (string triggerName)
 Waits until an Event/Tag in the current animation is reached.
 
Coroutine Fade (float start, float end, float duration, eEaseCurve curve=eEaseCurve.Smooth)
 Fade the sprite's alpha. (0.0f being fully transparent, 1.0f being fully opaque.)
 
void FadeBG (float start, float end, float duration, eEaseCurve curve=eEaseCurve.InOutSmooth)
 Fade the sprite's alpha (non-blocking). (0.0f being fully transparent, 1.0f being fully opaque.)
 
- Public Member Functions inherited from IGuiControl
void Show ()
 Shows the control.
 
void Hide ()
 Hides the control.
 
void SetPosition (float x, float y)
 Sets the position of the control. Note that this will be overridden if using AlignTo or FitTo component.
 
GuiControl DuplicateControl (string name=null, IGuiControl parent=null)
 Duplicates the control. Useful for adding elements dynamically to a gui. You can optionally specify a new name for the control, and a parent object (such as a grid container)
 

Property Documentation

◆ Anim

new string Anim
getset

Gets/Sets the Sprite (or animation) for the gui image.

You can use any sprite/anim in the Gui's own folder, the Gui\GuiSprites or Gui\GuiAnimations folders, or the Inventory folder.

Note, that by default gui Image controls may not have a "Power Sprite Animation" component, and this needs to be added for them to play animations.

See also
PlayAnimation

Implements IGuiControl.

◆ Animating

bool Animating
get

Whether an animation triggered by PlayAnimation() is currently playing. Note- this does not include animations set using the Anim property.

See also
Anim
PlayAnimation

◆ Alpha

float Alpha
getset

Gets/Sets the transparency of the sprite. (0.0f being fully transparent, 1.0f being fully opaque.)

Member Function Documentation

◆ PauseAnimation()

void PauseAnimation ( )

Pauses the currently playing animation. Only works for animations played with PlayAnimationBG()

See also
PlayAnimationBG()

◆ ResumeAnimation()

void ResumeAnimation ( )

Resumes playing the current animation after PauseAnimation() was called.

See also
PauseAnimation()

◆ StopAnimation()

void StopAnimation ( )

Stops the current animation- returns to Idle animation. Only works for animations played with PlayAnimationBG()

See also
PlayAnimationBG()

◆ PlayAnimation()

Coroutine PlayAnimation ( string animName)

Plays an animation on the control. Will block the script until complete.

After finishing, the control returns to it's default sprite/animation specified by the 'Anim' property. Note, that by default gui Image controls may not have a "Power Sprite Animation" component, and this needs to be added for them to play animations.

See also
Animating
PlayAnimation
PlayAnimationBG
PauseAnimation
StopAnimation
Anim

◆ PlayAnimationBG()

void PlayAnimationBG ( string animName)

Play an animation on the control without halting the script. Will return to idle after animation ends, unless pauseAtEnd is true.

After finishing, the control returns to it's default sprite/animation specified by the 'Anim' property. Note, that by default gui Image controls may not have a "Power Sprite Animation" component, and this needs to be added for them to play animations.

See also
Animating
PlayAnimation
PlayAnimationBG
PauseAnimation
StopAnimation
Anim

◆ AddAnimationTrigger()

void AddAnimationTrigger ( string triggerName,
bool removeAfterTriggering,
System.Action action )

Adds a function to be called on an animation event here. Eg: to play a sound or effect on an animation tag.

Usage: Add an event to the anim called "Trigger" with a string matching the tag you want (eg: "Shoot") Then call C.Player.AddAnimationTrigger( "Shoot", true, ()=>Audio.PlaySound("Gunshot") );

See also
WaitForAnimationTrigger
RemoveAnimationTrigger

◆ RemoveAnimationTrigger()

void RemoveAnimationTrigger ( string triggerName)

Removes an existing animation trigger.

See also
AddAnimationTrigger

◆ WaitForAnimTrigger()

Coroutine WaitForAnimTrigger ( string triggerName)

Waits until an Event/Tag in the current animation is reached.

Usage:

  • Add an event to an animation, eg: 'Shoot'.
  • Play the animation in the background
  • Call C.Player.WaitForAnimTrigger("Shoot");.
  • The script will pause until that event is hit before continuing

Example: Using it to play a sound and shake the screen at the time in an animation when the player shoots a gun:

C.Dave.PlayAnimationBG("AimAndFireGun");
C.Dave.WaitForAnimTrigger("Shoot");
Audio.Play("Bang");
Camera.Shake();
Barney: Ouch!
See also
AddAnimationTrigger

◆ Fade()

Coroutine Fade ( float start,
float end,
float duration,
eEaseCurve curve = eEaseCurve.Smooth )

Fade the sprite's alpha. (0.0f being fully transparent, 1.0f being fully opaque.)

◆ FadeBG()

void FadeBG ( float start,
float end,
float duration,
eEaseCurve curve = eEaseCurve.InOutSmooth )

Fade the sprite's alpha (non-blocking). (0.0f being fully transparent, 1.0f being fully opaque.)