CCPUTextureAnimator.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /****************************************************************************
  2. Copyright (C) 2013 Henry van Merode. All rights reserved.
  3. Copyright (c) 2015-2016 Chukong Technologies Inc.
  4. Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
  5. http://www.cocos2d-x.org
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12. The above copyright notice and this permission notice shall be included in
  13. all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. THE SOFTWARE.
  21. ****************************************************************************/
  22. #ifndef __CC_PU_PARTICLE_3D_TEXTURE_ANIMATOR_H__
  23. #define __CC_PU_PARTICLE_3D_TEXTURE_ANIMATOR_H__
  24. #include "extensions/Particle3D/PU/CCPUAffector.h"
  25. #include "base/ccTypes.h"
  26. NS_CC_BEGIN
  27. class CC_DLL PUTextureAnimator : public PUAffector
  28. {
  29. public:
  30. enum TextureAnimationType
  31. {
  32. TAT_LOOP,
  33. TAT_UP_DOWN,
  34. TAT_RANDOM
  35. };
  36. // Constants
  37. static const float DEFAULT_TIME_STEP;
  38. static const unsigned short DEFAULT_TEXCOORDS_START;
  39. static const unsigned short DEFAULT_TEXCOORDS_END;
  40. static const TextureAnimationType DEFAULT_ANIMATION_TYPE;
  41. static const bool DEFAULT_START_RANDOM;
  42. static PUTextureAnimator* create();
  43. virtual void preUpdateAffector(float deltaTime) override;
  44. virtual void initParticleForEmission(PUParticle3D* particle) override;
  45. virtual void updatePUAffector(PUParticle3D *particle, float deltaTime) override;
  46. /** Returns the AnimationTimeStep. The AnimationTimeStep defines the time between each animation frame. */
  47. float getAnimationTimeStep(void) const;
  48. /** Set the AnimationTimeStep */
  49. void setAnimationTimeStep(float animationTimeStep);
  50. /** Returns the type of texture animation. */
  51. TextureAnimationType getTextureAnimationType(void) const;
  52. /** Set the type of texture animation. */
  53. void setTextureAnimationType(TextureAnimationType textureAnimationType);
  54. /** Todo */
  55. unsigned short getTextureCoordsStart(void) const;
  56. /** Todo */
  57. void setTextureCoordsStart(unsigned short textureCoordsStart);
  58. /** Todo */
  59. unsigned short getTextureCoordsEnd(void) const;
  60. /** Todo */
  61. void setTextureCoordsEnd(unsigned short textureCoordsEnd);
  62. /** Todo */
  63. bool isStartRandom(void) const;
  64. /** Todo */
  65. void setStartRandom(bool startRandom);
  66. virtual void copyAttributesTo (PUAffector* affector) override;
  67. CC_CONSTRUCTOR_ACCESS:
  68. PUTextureAnimator(void);
  69. virtual ~PUTextureAnimator(void);
  70. protected:
  71. /** Todo.
  72. */
  73. void determineNextTextureCoords(PUParticle3D* visualParticle);
  74. protected:
  75. float _animationTimeStep;
  76. float _animationTimeStepCount;
  77. bool _startRandom;
  78. bool _animationTimeStepSet;
  79. bool _nextIndex;
  80. TextureAnimationType _textureAnimationType;
  81. unsigned short _textureCoordsStart;
  82. unsigned short _textureCoordsEnd;
  83. };
  84. NS_CC_END
  85. #endif