2013-09-20 22:23:13 +08:00
|
|
|
/****************************************************************************
|
2014-01-07 11:47:11 +08:00
|
|
|
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
2013-12-26 16:29:59 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
2013-09-20 22:23:13 +08:00
|
|
|
|
|
|
|
#ifndef __ActionObject_H__
|
|
|
|
#define __ActionObject_H__
|
|
|
|
|
|
|
|
#include "cocos2d.h"
|
|
|
|
#include "CCActionNode.h"
|
2013-12-24 20:33:55 +08:00
|
|
|
#include "cocostudio/DictionaryHelper.h"
|
2013-09-20 22:23:13 +08:00
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
namespace cocostudio {
|
2013-09-20 22:23:13 +08:00
|
|
|
|
2013-11-20 12:04:47 +08:00
|
|
|
/**
|
2013-12-26 16:29:59 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-10-15 18:00:03 +08:00
|
|
|
class ActionObject:public cocos2d::Object
|
2013-09-20 22:23:13 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-12-26 16:29:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Default constructor
|
|
|
|
*/
|
|
|
|
ActionObject();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default destructor
|
|
|
|
*/
|
|
|
|
virtual ~ActionObject();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets name for object
|
|
|
|
*
|
|
|
|
* @param name name of object
|
|
|
|
*/
|
2013-09-20 22:23:13 +08:00
|
|
|
void setName(const char* name);
|
2013-12-26 16:29:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets name for object
|
|
|
|
*
|
|
|
|
* @return name of object
|
|
|
|
*/
|
2013-09-20 22:23:13 +08:00
|
|
|
const char* getName();
|
2013-12-26 16:29:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets if the action will loop play.
|
|
|
|
*
|
|
|
|
* @param bLoop that if the action will loop play
|
|
|
|
*/
|
2013-09-20 22:23:13 +08:00
|
|
|
void setLoop(bool bLoop);
|
2013-12-26 16:29:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets if the action will loop play.
|
|
|
|
*
|
|
|
|
* @return that if the action will loop play
|
|
|
|
*/
|
2013-09-20 22:23:13 +08:00
|
|
|
bool getLoop();
|
2013-12-26 16:29:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the time interval of frame.
|
|
|
|
*
|
|
|
|
* @param fTime the time interval of frame
|
|
|
|
*/
|
2013-09-20 22:23:13 +08:00
|
|
|
void setUnitTime(float fTime);
|
2013-12-26 16:29:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the time interval of frame.
|
|
|
|
*
|
|
|
|
* @return fTime the time interval of frame
|
|
|
|
*/
|
2013-09-20 22:23:13 +08:00
|
|
|
float getUnitTime();
|
|
|
|
|
2013-12-26 16:29:59 +08:00
|
|
|
/**
|
|
|
|
* Sets the current time of frame.
|
|
|
|
*
|
|
|
|
* @param fTime the current time of frame
|
|
|
|
*/
|
|
|
|
void setCurrentTime(float fTime);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the current time of frame.
|
|
|
|
*
|
|
|
|
* @return fTime the current time of frame
|
|
|
|
*/
|
2013-09-20 22:23:13 +08:00
|
|
|
float getCurrentTime();
|
2013-12-26 16:29:59 +08:00
|
|
|
|
2013-12-24 20:33:55 +08:00
|
|
|
/**
|
|
|
|
* Gets the total time of frame.
|
|
|
|
*
|
|
|
|
* @return fTime the current time of frame
|
|
|
|
*/
|
|
|
|
float getTotalTime();
|
|
|
|
|
|
|
|
/**
|
2013-12-26 16:29:59 +08:00
|
|
|
* Return if the action is playing.
|
|
|
|
*
|
|
|
|
* @return true if the action is playing, false the otherwise
|
|
|
|
*/
|
2013-09-20 22:23:13 +08:00
|
|
|
bool isPlaying();
|
|
|
|
|
2013-12-26 16:29:59 +08:00
|
|
|
/**
|
|
|
|
* Play the action.
|
|
|
|
*/
|
2013-09-20 22:23:13 +08:00
|
|
|
void play();
|
|
|
|
|
2013-12-24 20:33:55 +08:00
|
|
|
/**
|
|
|
|
* Play the action.
|
|
|
|
*
|
|
|
|
* @ Action Call Back
|
|
|
|
*/
|
|
|
|
void play(cocos2d::CallFunc* func);
|
|
|
|
|
2013-12-26 16:29:59 +08:00
|
|
|
/**
|
2013-12-24 20:33:55 +08:00
|
|
|
* Pause the action.
|
2013-12-26 16:29:59 +08:00
|
|
|
*/
|
2013-09-20 22:23:13 +08:00
|
|
|
void pause();
|
2013-12-26 16:29:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Stop the action.
|
|
|
|
*/
|
2013-09-20 22:23:13 +08:00
|
|
|
void stop();
|
|
|
|
|
2013-12-26 16:29:59 +08:00
|
|
|
/**
|
|
|
|
* Adds a ActionNode to play the action.
|
|
|
|
*
|
|
|
|
* @node the ActionNode which will play the action
|
|
|
|
*/
|
2013-09-20 22:23:13 +08:00
|
|
|
void addActionNode(ActionNode* node);
|
2013-12-26 16:29:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes a ActionNode which play the action.
|
|
|
|
*
|
|
|
|
* @node the ActionNode which play the action
|
|
|
|
*/
|
2013-09-20 22:23:13 +08:00
|
|
|
void removeActionNode(ActionNode* node);
|
|
|
|
|
2013-12-26 16:29:59 +08:00
|
|
|
/*update frame method*/
|
2013-09-20 22:23:13 +08:00
|
|
|
void updateToFrameByTime(float fTime);
|
|
|
|
|
2013-12-26 16:29:59 +08:00
|
|
|
/*init properties with a json dictionary*/
|
2013-12-24 20:33:55 +08:00
|
|
|
void initWithDictionary(const rapidjson::Value& dic,Object* root);
|
2013-11-08 14:34:24 +08:00
|
|
|
|
2013-12-26 16:29:59 +08:00
|
|
|
/*scheduler update function*/
|
2013-11-08 14:34:24 +08:00
|
|
|
void simulationActionUpdate(float dt);
|
2013-09-20 22:23:13 +08:00
|
|
|
protected:
|
2013-12-25 19:46:09 +08:00
|
|
|
cocos2d::Vector<ActionNode*> _actionNodeList;/*actionnode*/
|
2013-09-20 22:23:13 +08:00
|
|
|
std::string _name;
|
|
|
|
bool _loop;
|
|
|
|
bool _bPause;
|
|
|
|
bool _bPlaying;
|
|
|
|
float _fUnitTime;
|
|
|
|
float _currentTime;
|
2013-11-08 14:34:24 +08:00
|
|
|
cocos2d::Scheduler *_pScheduler;
|
2013-12-24 20:33:55 +08:00
|
|
|
cocos2d::CallFunc *_CallBack;
|
|
|
|
float _fTotalTime;
|
2013-09-20 22:23:13 +08:00
|
|
|
};
|
|
|
|
|
2013-10-15 18:00:03 +08:00
|
|
|
}
|
2013-09-20 22:23:13 +08:00
|
|
|
|
|
|
|
#endif
|