CCActionProgressTimer.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /****************************************************************************
  2. Copyright (C) 2010 Lam Pham
  3. Copyright (c) 2010-2012 cocos2d-x.org
  4. Copyright (c) 2013-2017 Chukong Technologies Inc.
  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 __ACTION_CCPROGRESS_TIMER_H__
  23. #define __ACTION_CCPROGRESS_TIMER_H__
  24. #include "2d/CCActionInterval.h"
  25. NS_CC_BEGIN
  26. /**
  27. * @addtogroup actions
  28. * @{
  29. */
  30. /**
  31. @brief Progress to percentage.
  32. @details This action show the target node from current percentage to the specified percentage.
  33. You should specify the destination percentage when creating the action.
  34. @since v0.99.1
  35. */
  36. class CC_DLL ProgressTo : public ActionInterval
  37. {
  38. public:
  39. /**
  40. * @brief Create and initializes with a duration and a destination percentage.
  41. * @param duration Specify the duration of the ProgressTo action. It's a value in seconds.
  42. * @param percent Specify the destination percentage.
  43. * @return If the creation success, return a pointer of ProgressTo action; otherwise, return nil.
  44. */
  45. static ProgressTo* create(float duration, float percent);
  46. //
  47. // Overrides
  48. //
  49. virtual ProgressTo* clone() const override;
  50. virtual ProgressTo* reverse() const override;
  51. virtual void startWithTarget(Node *target) override;
  52. virtual void update(float time) override;
  53. CC_CONSTRUCTOR_ACCESS:
  54. ProgressTo() {}
  55. virtual ~ProgressTo() {}
  56. /**
  57. * @brief Initializes with a duration and destination percentage.
  58. * @param duration Specify the duration of the ProgressTo action. It's a value in seconds.
  59. * @param percent Specify the destination percentage.
  60. * @return If the creation success, return true; otherwise, return false.
  61. */
  62. bool initWithDuration(float duration, float percent);
  63. protected:
  64. float _to;
  65. float _from;
  66. private:
  67. CC_DISALLOW_COPY_AND_ASSIGN(ProgressTo);
  68. };
  69. /**
  70. @brief Progress from a percentage to another percentage.
  71. @since v0.99.1
  72. */
  73. class CC_DLL ProgressFromTo : public ActionInterval
  74. {
  75. public:
  76. /**
  77. * @brief Create and initializes the action with a duration, a "from" percentage and a "to" percentage.
  78. * @param duration Specify the duration of the ProgressFromTo action. It's a value in seconds.
  79. * @param fromPercentage Specify the source percentage.
  80. * @param toPercentage Specify the destination percentage.
  81. * @return If the creation success, return a pointer of ProgressFromTo action; otherwise, return nil.
  82. */
  83. static ProgressFromTo* create(float duration, float fromPercentage, float toPercentage);
  84. //
  85. // Overrides
  86. //
  87. virtual ProgressFromTo* clone() const override;
  88. virtual ProgressFromTo* reverse() const override;
  89. virtual void startWithTarget(Node *target) override;
  90. virtual void update(float time) override;
  91. CC_CONSTRUCTOR_ACCESS:
  92. ProgressFromTo() {}
  93. virtual ~ProgressFromTo() {}
  94. /**
  95. * @brief Initializes the action with a duration, a "from" percentage and a "to" percentage.
  96. * @param duration Specify the duration of the ProgressFromTo action. It's a value in seconds.
  97. * @param fromPercentage Specify the source percentage.
  98. * @param toPercentage Specify the destination percentage.
  99. * @return If the creation success, return true; otherwise, return false.
  100. */
  101. bool initWithDuration(float duration, float fromPercentage, float toPercentage);
  102. protected:
  103. float _to;
  104. float _from;
  105. private:
  106. CC_DISALLOW_COPY_AND_ASSIGN(ProgressFromTo);
  107. };
  108. // end of actions group
  109. /// @}
  110. NS_CC_END
  111. #endif // __ACTION_CCPROGRESS_TIMER_H__