CCPUDoScaleEventHandler.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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_DO_SCALE_EVENT_HANDLER_H__
  23. #define __CC_PU_PARTICLE_3D_DO_SCALE_EVENT_HANDLER_H__
  24. #include "base/CCRef.h"
  25. #include "math/CCMath.h"
  26. #include "extensions/Particle3D/PU/CCPUEventHandler.h"
  27. #include <vector>
  28. #include <string>
  29. NS_CC_BEGIN
  30. struct PUParticle3D;
  31. class PUParticleSystem3D;
  32. class CC_DLL PUDoScaleEventHandler : public PUEventHandler
  33. {
  34. public:
  35. enum ScaleType
  36. {
  37. ST_TIME_TO_LIVE,
  38. ST_VELOCITY
  39. };
  40. // Constants
  41. static const ScaleType DEFAULT_SCALE_TYPE;
  42. static const float DEFAULT_SCALE_FRACTION;
  43. static PUDoScaleEventHandler* create();
  44. /** Returns the scale type
  45. */
  46. const ScaleType& getScaleType(void) const;
  47. /** Set the scale type. This scale type identifies to which attribute the scale factor is applied.
  48. */
  49. void setScaleType(const ScaleType& scaleType);
  50. /** Returns the scale fraction
  51. */
  52. float getScaleFraction() const;
  53. /** Set the scale fraction. This scale fraction value is used to scale different attributes if the
  54. event handler is called.
  55. */
  56. void setScaleFraction(const float scaleFraction);
  57. /**
  58. */
  59. virtual void handle (PUParticleSystem3D* particleSystem, PUParticle3D* particle, float timeElapsed) override;
  60. virtual void copyAttributesTo (PUEventHandler* eventHandler) override;
  61. CC_CONSTRUCTOR_ACCESS:
  62. PUDoScaleEventHandler(void);
  63. virtual ~PUDoScaleEventHandler(void) {};
  64. protected:
  65. float _scaleFraction;
  66. ScaleType _scaleType;
  67. };
  68. NS_CC_END
  69. #endif