CCPUDoScaleEventHandler.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /****************************************************************************
  2. Copyright (C) 2013 Henry van Merode. All rights reserved.
  3. Copyright (c) 2015-2017 Chukong Technologies Inc.
  4. http://www.cocos2d-x.org
  5. Permission is hereby granted, free of charge, to any person obtaining a copy
  6. of this software and associated documentation files (the "Software"), to deal
  7. in the Software without restriction, including without limitation the rights
  8. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. copies of the Software, and to permit persons to whom the Software is
  10. furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19. THE SOFTWARE.
  20. ****************************************************************************/
  21. #ifndef __CC_PU_PARTICLE_3D_DO_SCALE_EVENT_HANDLER_H__
  22. #define __CC_PU_PARTICLE_3D_DO_SCALE_EVENT_HANDLER_H__
  23. #include "base/CCRef.h"
  24. #include "math/CCMath.h"
  25. #include "extensions/Particle3D/PU/CCPUEventHandler.h"
  26. #include <vector>
  27. #include <string>
  28. NS_CC_BEGIN
  29. struct PUParticle3D;
  30. class PUParticleSystem3D;
  31. class CC_DLL PUDoScaleEventHandler : public PUEventHandler
  32. {
  33. public:
  34. enum ScaleType
  35. {
  36. ST_TIME_TO_LIVE,
  37. ST_VELOCITY
  38. };
  39. // Constants
  40. static const ScaleType DEFAULT_SCALE_TYPE;
  41. static const float DEFAULT_SCALE_FRACTION;
  42. static PUDoScaleEventHandler* create();
  43. /** Returns the scale type
  44. */
  45. const ScaleType& getScaleType(void) const;
  46. /** Set the scale type. This scale type identifies to which attribute the scale factor is applied.
  47. */
  48. void setScaleType(const ScaleType& scaleType);
  49. /** Returns the scale fraction
  50. */
  51. float getScaleFraction() const;
  52. /** Set the scale fraction. This scale fraction value is used to scale different attributes if the
  53. event handler is called.
  54. */
  55. void setScaleFraction(const float scaleFraction);
  56. /**
  57. */
  58. virtual void handle (PUParticleSystem3D* particleSystem, PUParticle3D* particle, float timeElapsed) override;
  59. virtual void copyAttributesTo (PUEventHandler* eventHandler) override;
  60. CC_CONSTRUCTOR_ACCESS:
  61. PUDoScaleEventHandler(void);
  62. virtual ~PUDoScaleEventHandler(void) {};
  63. protected:
  64. float _scaleFraction;
  65. ScaleType _scaleType;
  66. };
  67. NS_CC_END
  68. #endif