PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/com.project.flickhockey.Flick_Hockey/src/com/project/flickhockey/AnimatedGraphic.java

https://github.com/1002064/BDH-FlickHockey
Java | 45 lines | 29 code | 8 blank | 8 comment | 3 complexity | 372ef8a0fe8848533bfe619bb142e34d MD5 | raw file
  1. package com.project.flickhockey;
  2. import android.graphics.Bitmap;
  3. public class AnimatedGraphic extends Graphic
  4. {
  5. protected int frameNumber;
  6. protected int frameTotal;
  7. protected int frameDelay;
  8. protected int frameTimer;
  9. public AnimatedGraphic(Bitmap bitmap)
  10. {
  11. super(bitmap);
  12. }
  13. //single row animation function, likely overridden in inheriting classes
  14. public void Animate()
  15. {
  16. // if it's time to change frame
  17. if (frameTimer >= frameDelay)
  18. {
  19. // if the frame is not the final frame of the animation
  20. if (frameNumber < frameTotal)
  21. {
  22. // move to the next frame
  23. frameNumber++;
  24. }
  25. // if the frame is the final frame of the animation
  26. else
  27. {
  28. // move back to the start of the animation
  29. frameNumber = 0;
  30. }
  31. // reset the timer
  32. frameTimer = 0;
  33. }
  34. // increment the timer
  35. frameTimer++;
  36. }
  37. }