createeffects.adoc 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. = createeffects
  2. :author:
  3. :revnumber:
  4. :revdate: 2016/03/17 20:48
  5. :relfileprefix: ../../../
  6. :imagesdir: ../../..
  7. ifdef::env-github,env-browser[:outfilesuffix: .adoc]
  8. == Effect
  9. Effects are used to graphically enhance your UI with transitions, movement, image manipulation & audio.
  10. === Creating an Effect
  11. [source,java]
  12. ----
  13. Effect effect = new Effect(
  14. Effect.EffectType.FadeIn, // The type of effect to use
  15. Effect.EffectEvent.Show, // The event that the effect is associated with
  16. 2.2f // The duration of time over which the effect executes (2.2 seconds)
  17. );
  18. effect.setEffectElement(someElement); // The Element to fade into the screen
  19. screen.getEffectManager().applyEffect(effect); // Tell the effect manager to execute
  20. ----
  21. === Creating Automated Effects
  22. Some components have effects associated with them by default, for instance buttons hover and pressed states. You can create effects for these states (or replace the existing effects defined in the style XMLs) like so:
  23. [source,java]
  24. ----
  25. Effect effect = new Effect(
  26. Effect.EffectType.Pulse, // The type of effect to use
  27. Effect.EffectEvent.Hover, // The event that the effect is associated with
  28. 2.2f // The duration of time over which the effect executes (2.2 seconds)
  29. );
  30. someButton.addEffect(effect);
  31. ----
  32. At this point, the button will use the following effect anytime the user mouseovers the button, as well as manage any setting required to execute the effect properly.
  33. [NOTE]
  34. ====
  35. Some effects require a blend image (to pulse to and from in the above case) +
  36. Some require a blend color +
  37. Others require a direction
  38. See below for details
  39. ====
  40. === Methods Specific to Setting Up Effects
  41. [source,java]
  42. ----
  43. effect.setElement(Element element);
  44. // Used with Pulse, ImageSwap
  45. effect.setBlendImage(Texture blendImage);
  46. // Used with PulseColor, ColorSwap
  47. effect.setColor(ColorRGBA blendColor);
  48. // Used with SlideIn, SlideOut
  49. effect.setEffectDirection(Effect.EffectDirection direction);
  50. // Used with SlideTo
  51. effect.setEffectDestination(Vector2f destination);
  52. // Used with any effect
  53. effect.setAudioFile(String styleTagID);
  54. effect.setAudioVolume(float volume);
  55. ----
  56. === Other Methods Specific to Effect
  57. [source,java]
  58. ----
  59. effect.getElement();
  60. effect.getDuration();
  61. effect.getIsActive();
  62. effect.getEffectType();
  63. effect.getEffectEvent();
  64. effect.getEffectDirection();
  65. effect.getAudioFile();
  66. effect.getAudioVolume();
  67. // Use with hide effects. **only use if you want the element associated
  68. // with the effect to be destroy & garbage collected
  69. effect.setDestroyOnHide(boolean destroyOnHide);
  70. ----
  71. === Enums
  72. Effect.EffectType
  73. * FadeIn
  74. * FadeOut
  75. * ZoomIn
  76. * ZoomOut
  77. * SlideIn
  78. * SlideOut
  79. * SpinIn
  80. * SpinOut
  81. * Pulse
  82. * ColorSwap
  83. * PulseColor
  84. * ImageSwap
  85. * Saturate
  86. * Desaturate
  87. Effect.EffectEvent
  88. * GetFocus
  89. * LoseFocus
  90. * Show
  91. * Hide
  92. * Hover
  93. * Press
  94. * Release
  95. * TabFocus
  96. * LoseTabFocus
  97. Effect.EffectDirection
  98. * Top
  99. * Bottom
  100. * Left
  101. * Right