Testing out JmonkeyEngine to make a game in Scala with Akka Actors within a pure FP layer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
2.2 KiB

4 years ago
  1. package com.jme3
  2. import com.jme3.input.Action
  3. package object animation {
  4. implicit class AnimChannelWrap(val uval: AnimChannel) extends AnyVal {
  5. /**
  6. * Set the current animation that is played by this AnimChannel.
  7. * <p>
  8. * See {@link #setAnim(java.lang.String, float)}.
  9. * The blendTime argument by default is 150 milliseconds.
  10. *
  11. * @param action The action (name) of the animation to play
  12. */
  13. def setAnim(action: Action): Unit = uval.setAnim(action.name)
  14. /**
  15. * Set the current animation that is played by this AnimChannel.
  16. * <p>
  17. * This resets the time to zero, and optionally blends the animation
  18. * over <code>blendTime</code> seconds with the currently playing animation.
  19. * Notice that this method will reset the control's speed to 1.0.
  20. *
  21. * @param action The action (name) of the animation to play
  22. * @param blendTime The blend time over which to blend the new animation
  23. * with the old one. If zero, then no blending will occur and the new
  24. * animation will be applied instantly.
  25. */
  26. def setAnim(action: Action, blendTime: Float): Unit = uval.setAnim(action.name, blendTime)
  27. }
  28. implicit class AnimEventListenerWrap(val uval: AnimEventListener) extends AnyVal {
  29. /**
  30. * Invoked when an animation "cycle" is done. For non-looping animations,
  31. * this event is invoked when the animation is finished playing. For
  32. * looping animations, this even is invoked each time the animation is restarted.
  33. *
  34. * @param control The control to which the listener is assigned.
  35. * @param channel The channel being altered
  36. * @param action The new animation action that is done.
  37. */
  38. def onAnimCycleDone(control: AnimControl, channel: AnimChannel, action: Action): Unit =
  39. uval.onAnimCycleDone(control, channel, action.name)
  40. /**
  41. * Invoked when a animation is set to play by the user on the given channel.
  42. *
  43. * @param control The control to which the listener is assigned.
  44. * @param channel The channel being altered
  45. * @param action The new animation action set.
  46. */
  47. def onAnimChange(control: AnimControl, channel: AnimChannel, action: Action): Unit =
  48. uval.onAnimChange(control, channel, action.name)
  49. }
  50. }