bouncer.c 868 B

12345678910111213141516171819202122232425262728293031323334353637
  1. // -----------------------------------------------------------
  2. class Bouncer
  3. {
  4. reference float amount;
  5. reference float speed;
  6. protected float m_orginal_width;
  7. protected float m_orginal_height;
  8. protected Widget m_root;
  9. protected ref AnimatorTimer m_anim;
  10. // -----------------------------------------------------------
  11. void Bouncer()
  12. {
  13. m_anim = new AnimatorTimer();
  14. }
  15. // -----------------------------------------------------------
  16. protected void Update()
  17. {
  18. Print("Update");
  19. if (m_root)
  20. {
  21. float p = amount * m_anim.GetValue();
  22. m_root.SetSize(m_orginal_width + (m_orginal_width * p), m_orginal_height - (m_orginal_height * p));
  23. }
  24. }
  25. // -----------------------------------------------------------
  26. void OnWidgetScriptInit(Widget w)
  27. {
  28. m_root = w;
  29. m_root.GetSize(m_orginal_width, m_orginal_height);
  30. m_anim.AnimateLoop(speed);
  31. }
  32. };