CCTimeLine.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /****************************************************************************
  2. Copyright (c) 2013 cocos2d-x.org
  3. http://www.cocos2d-x.org
  4. Permission is hereby granted, free of charge, to any person obtaining a copy
  5. of this software and associated documentation files (the "Software"), to deal
  6. in the Software without restriction, including without limitation the rights
  7. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. copies of the Software, and to permit persons to whom the Software is
  9. furnished to do so, subject to the following conditions:
  10. The above copyright notice and this permission notice shall be included in
  11. all copies or substantial portions of the Software.
  12. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  13. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  14. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  15. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  16. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  17. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  18. THE SOFTWARE.
  19. ****************************************************************************/
  20. #ifndef __CCTIMELINE_H__
  21. #define __CCTIMELINE_H__
  22. #include "editor-support/cocostudio/ActionTimeline/CCFrame.h"
  23. #include "editor-support/cocostudio/ActionTimeline/CCTimelineMacro.h"
  24. #include "editor-support/cocostudio/CocosStudioExport.h"
  25. NS_TIMELINE_BEGIN
  26. class ActionTimeline;
  27. class CC_STUDIO_DLL Timeline : public cocos2d::Ref
  28. {
  29. public:
  30. static Timeline* create();
  31. Timeline();
  32. virtual ~Timeline();
  33. virtual void gotoFrame(int frameIndex);
  34. virtual void stepToFrame(int frameIndex);
  35. virtual const cocos2d::Vector<Frame*>& getFrames() const { return _frames; }
  36. virtual void addFrame(Frame* frame);
  37. virtual void insertFrame(Frame* frame, int index);
  38. virtual void removeFrame(Frame* frame);
  39. virtual void setActionTag(int tag) { _actionTag = tag; }
  40. virtual int getActionTag() const { return _actionTag; }
  41. virtual void setNode(cocos2d::Node* node);
  42. virtual cocos2d::Node* getNode() const;
  43. virtual void setActionTimeline(ActionTimeline* action) { _ActionTimeline = action; }
  44. virtual ActionTimeline* getActionTimeline() const { return _ActionTimeline; }
  45. virtual Timeline* clone();
  46. protected:
  47. virtual void apply(unsigned int frameIndex);
  48. virtual void binarySearchKeyFrame (unsigned int frameIndex);
  49. virtual void updateCurrentKeyFrame(unsigned int frameIndex);
  50. cocos2d::Vector<Frame*> _frames;
  51. Frame* _currentKeyFrame;
  52. unsigned int _currentKeyFrameIndex;
  53. unsigned int _fromIndex;
  54. unsigned int _toIndex;
  55. unsigned int _betweenDuration;
  56. unsigned int _actionTag;
  57. ActionTimeline* _ActionTimeline;
  58. cocos2d::Node* _node;
  59. };
  60. NS_TIMELINE_END
  61. #endif /*__CCTIMELINE_H__*/