test40.nim 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # --- Test 40. Use AnimationPlayer. --- #
  2. import nodesnim
  3. Window("AnimationPlayer")
  4. build:
  5. - Scene scene:
  6. - ColorRect rect:
  7. color: Color(0, 0, 0)
  8. call resize(100, 100)
  9. - ColorRect rect1:
  10. color: Color(0, 0, 0)
  11. call resize(100, 100)
  12. call move(0, 150)
  13. - ColorRect rect2:
  14. color: Color(0.5, 0.8, 0.5)
  15. call resize(100, 100)
  16. call move(0, 300)
  17. - AnimationPlayer animation:
  18. call addState(rect.color.r.addr, @[(tick: 0, value: 0.0), (tick: 200, value: 1.0)])
  19. call addState(rect.position.x.addr, @[(tick: 0, value: 0.0), (tick: 100, value: 250.0)])
  20. call setDuration(200)
  21. call play()
  22. mode: ANIMATION_NORMAL # Default animation mode.
  23. - AnimationPlayer animation1:
  24. call addState(rect1.position.x.addr, @[(tick: 0, value: 0.0), (tick: 100, value: 250.0)])
  25. call setDuration(200)
  26. call play()
  27. mode: ANIMATION_EASE
  28. - AnimationPlayer animation2:
  29. call addState(rect2.position.x.addr, @[(tick: 0, value: 0.0), (tick: 100, value: 250.0)])
  30. call setDuration(200)
  31. call play()
  32. mode: ANIMATION_BEZIER
  33. bezier: (0.8, 0.9)
  34. addMainScene(scene)
  35. windowLaunch()