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.

72 lines
2.4 KiB

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