SingleAnnimation.cpp 794 B

123456789101112131415161718192021222324252627282930313233
  1. #include "SingleAnnimation.h"
  2. SingleAnimation::SingleAnimation( float x, float y, float width, float height, Resource *resource )
  3. : GameObject( NICHTS, (int)x, (int)y, (int)width, (int)height )
  4. {
  5. this->resource = resource;
  6. currentImage = 0;
  7. nextImage = 0.075;
  8. texturScale = 1;
  9. textur = resource->getImage( currentImage );
  10. }
  11. SingleAnimation::~SingleAnimation()
  12. {
  13. resource->release();
  14. }
  15. // gibt 1 zurück wenn die annimation vorbei ist
  16. bool SingleAnimation::tick( double zeit )
  17. {
  18. nextImage -= zeit;
  19. if( nextImage <= 0 )
  20. {
  21. nextImage += 0.075;
  22. currentImage++;
  23. if( currentImage >= resource->getImageCount() )
  24. return 1;
  25. textur->release();
  26. textur = resource->getImage( currentImage );
  27. }
  28. return 0;
  29. }