CCPUEventHandler.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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_EVENT_HANDLER_H__
  23. #define __CC_PU_PARTICLE_3D_EVENT_HANDLER_H__
  24. #include "base/CCRef.h"
  25. #include "math/CCMath.h"
  26. #include <vector>
  27. #include <string>
  28. NS_CC_BEGIN
  29. struct PUParticle3D;
  30. class PUObserver;
  31. class PUParticleSystem3D;
  32. class CC_DLL PUEventHandler : public Ref
  33. {
  34. public:
  35. /** Todo
  36. */
  37. const std::string& getName(void) const {return _name;};
  38. void setName(const std::string& name) {_name = name;};
  39. /** Todo
  40. */
  41. PUObserver* getParentObserver(void) const {return _parentObserver;};
  42. void setParentObserver(PUObserver* parentObserver) {_parentObserver = parentObserver;};
  43. /** Todo
  44. */
  45. const std::string& getEventHandlerType(void) const {return _eventHandlerType;};
  46. void setEventHandlerType(const std::string& eventHandlerType) {_eventHandlerType = eventHandlerType;};
  47. /** Notify that the event handler is rescaled.
  48. */
  49. virtual void notifyRescaled(const Vec3& scale){_eventHandlerScale = scale;};
  50. /** Todo
  51. */
  52. virtual void handle(PUParticleSystem3D* particleSystem, PUParticle3D* particle, float timeElapsed) = 0;
  53. virtual void copyAttributesTo (PUEventHandler* eventHandler);
  54. CC_CONSTRUCTOR_ACCESS:
  55. PUEventHandler();
  56. virtual ~PUEventHandler();
  57. protected:
  58. // Observer to which the eventhandler is associated.
  59. PUObserver* _parentObserver;
  60. // Type of event handler
  61. std::string _eventHandlerType;
  62. // Name of the eventHandler (optional)
  63. std::string _name;
  64. /** Although the scale is on a Particle System level, the event handler can also be scaled.
  65. */
  66. Vec3 _eventHandlerScale;
  67. };
  68. NS_CC_END
  69. #endif