mirror of https://github.com/axmolengine/axmol.git
Merge pull request #4614 from 2youyouo2/develop
update armature, using `const std::string&` instead of `const char*`
This commit is contained in:
commit
39c3bc10ed
|
@ -56,7 +56,7 @@ Armature *Armature::create()
|
|||
}
|
||||
|
||||
|
||||
Armature *Armature::create(const char *name)
|
||||
Armature *Armature::create(const std::string& name)
|
||||
{
|
||||
Armature *armature = new Armature();
|
||||
if (armature && armature->init(name))
|
||||
|
@ -68,7 +68,7 @@ Armature *Armature::create(const char *name)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Armature *Armature::create(const char *name, Bone *parentBone)
|
||||
Armature *Armature::create(const std::string& name, Bone *parentBone)
|
||||
{
|
||||
Armature *armature = new Armature();
|
||||
if (armature && armature->init(name, parentBone))
|
||||
|
@ -105,7 +105,7 @@ bool Armature::init()
|
|||
}
|
||||
|
||||
|
||||
bool Armature::init(const char *name)
|
||||
bool Armature::init(const std::string& name)
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
|
@ -121,14 +121,12 @@ bool Armature::init(const char *name)
|
|||
|
||||
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
|
||||
|
||||
_name = name == nullptr ? "" : name;
|
||||
_name = name;
|
||||
|
||||
ArmatureDataManager *armatureDataManager = ArmatureDataManager::getInstance();
|
||||
|
||||
if(_name.length() != 0)
|
||||
if(!_name.empty())
|
||||
{
|
||||
_name = name;
|
||||
|
||||
AnimationData *animationData = armatureDataManager->getAnimationData(name);
|
||||
CCASSERT(animationData, "AnimationData not exist! ");
|
||||
|
||||
|
@ -196,14 +194,14 @@ bool Armature::init(const char *name)
|
|||
return bRet;
|
||||
}
|
||||
|
||||
bool Armature::init(const char *name, Bone *parentBone)
|
||||
bool Armature::init(const std::string& name, Bone *parentBone)
|
||||
{
|
||||
_parentBone = parentBone;
|
||||
return init(name);
|
||||
}
|
||||
|
||||
|
||||
Bone *Armature::createBone(const char *boneName)
|
||||
Bone *Armature::createBone(const std::string& boneName)
|
||||
{
|
||||
Bone *existedBone = getBone(boneName);
|
||||
if(existedBone != nullptr)
|
||||
|
@ -233,12 +231,12 @@ Bone *Armature::createBone(const char *boneName)
|
|||
}
|
||||
|
||||
|
||||
void Armature::addBone(Bone *bone, const char *parentName)
|
||||
void Armature::addBone(Bone *bone, const std::string& parentName)
|
||||
{
|
||||
CCASSERT( bone != nullptr, "Argument must be non-nil");
|
||||
CCASSERT(_boneDic.at(bone->getName()) == nullptr, "bone already added. It can't be added again");
|
||||
|
||||
if (nullptr != parentName)
|
||||
if (!parentName.empty())
|
||||
{
|
||||
Bone *boneParent = _boneDic.at(parentName);
|
||||
if (boneParent)
|
||||
|
@ -278,13 +276,13 @@ void Armature::removeBone(Bone *bone, bool recursion)
|
|||
}
|
||||
|
||||
|
||||
Bone *Armature::getBone(const char *name) const
|
||||
Bone *Armature::getBone(const std::string& name) const
|
||||
{
|
||||
return _boneDic.at(name);
|
||||
}
|
||||
|
||||
|
||||
void Armature::changeBoneParent(Bone *bone, const char *parentName)
|
||||
void Armature::changeBoneParent(Bone *bone, const std::string& parentName)
|
||||
{
|
||||
CCASSERT(bone != nullptr, "bone must be added to the bone dictionary!");
|
||||
|
||||
|
@ -294,7 +292,7 @@ void Armature::changeBoneParent(Bone *bone, const char *parentName)
|
|||
bone->setParentBone(nullptr);
|
||||
}
|
||||
|
||||
if (parentName != nullptr)
|
||||
if (!parentName.empty())
|
||||
{
|
||||
Bone *boneParent = _boneDic.at(parentName);
|
||||
|
||||
|
|
|
@ -84,9 +84,9 @@ public:
|
|||
* @param name Armature will use the name to find the ArmatureData to initializes it.
|
||||
* @return A initialized armature which is marked as "autorelease".
|
||||
*/
|
||||
static Armature *create(const char *name);
|
||||
static Armature *create(const std::string& name);
|
||||
|
||||
static Armature *create(const char *name, Bone *parentBone);
|
||||
static Armature *create(const std::string& name, Bone *parentBone);
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -108,29 +108,29 @@ public:
|
|||
* Init an armature with specified name
|
||||
* @param name Armature name
|
||||
*/
|
||||
virtual bool init(const char *name);
|
||||
virtual bool init(const std::string& name);
|
||||
|
||||
virtual bool init(const char *name, Bone *parentBone);
|
||||
virtual bool init(const std::string& name, Bone *parentBone);
|
||||
/**
|
||||
* Add a Bone to this Armature,
|
||||
*
|
||||
* @param bone The Bone you want to add to Armature
|
||||
* @param parentName The parent Bone's name you want to add to . If it's nullptr, then set Armature to its parent
|
||||
*/
|
||||
virtual void addBone(Bone *bone, const char *parentName);
|
||||
virtual void addBone(Bone *bone, const std::string& parentName);
|
||||
/**
|
||||
* Get a bone with the specified name
|
||||
*
|
||||
* @param name The bone's name you want to get
|
||||
*/
|
||||
virtual Bone *getBone(const char *name) const;
|
||||
virtual Bone *getBone(const std::string& name) const;
|
||||
/**
|
||||
* Change a bone's parent with the specified parent name.
|
||||
*
|
||||
* @param bone The bone you want to change parent
|
||||
* @param parentName The new parent's name.
|
||||
*/
|
||||
virtual void changeBoneParent(Bone *bone, const char *parentName);
|
||||
virtual void changeBoneParent(Bone *bone, const std::string& parentName);
|
||||
/**
|
||||
* Remove a bone with the specified name. If recursion it will also remove child Bone recursionly.
|
||||
*
|
||||
|
@ -247,7 +247,7 @@ protected:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
Bone *createBone(const char *boneName );
|
||||
Bone *createBone(const std::string& boneName );
|
||||
|
||||
protected:
|
||||
ArmatureData *_armatureData;
|
||||
|
|
|
@ -164,11 +164,11 @@ float ArmatureAnimation::getSpeedScale() const
|
|||
}
|
||||
|
||||
|
||||
void ArmatureAnimation::play(const char *animationName, int durationTo, int loop)
|
||||
void ArmatureAnimation::play(const std::string& animationName, int durationTo, int loop)
|
||||
{
|
||||
CCASSERT(_animationData, "_animationData can not be null");
|
||||
|
||||
_movementData = _animationData->getMovement(animationName);
|
||||
_movementData = _animationData->getMovement(animationName.c_str());
|
||||
CCASSERT(_movementData, "_movementData can not be null");
|
||||
|
||||
//! Get key frame count
|
||||
|
@ -461,11 +461,11 @@ void ArmatureAnimation::setFrameEventCallFunc(Object *target, SEL_FrameEventCall
|
|||
_frameEventCallFunc = callFunc;
|
||||
}
|
||||
|
||||
void ArmatureAnimation::setMovementEventCallFunc(std::function<void(Armature *armature, MovementEventType movementType, const char *movementID)> listener)
|
||||
void ArmatureAnimation::setMovementEventCallFunc(std::function<void(Armature *armature, MovementEventType movementType, const std::string& movementID)> listener)
|
||||
{
|
||||
_movementEventListener = listener;
|
||||
}
|
||||
void ArmatureAnimation::setFrameEventCallFunc(std::function<void(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex)> listener)
|
||||
void ArmatureAnimation::setFrameEventCallFunc(std::function<void(Bone *bone, const std::string& frameEventName, int originFrameIndex, int currentFrameIndex)> listener)
|
||||
{
|
||||
_frameEventListener = listener;
|
||||
}
|
||||
|
@ -477,7 +477,7 @@ void ArmatureAnimation::setUserObject(Object *pUserObject)
|
|||
_userObject = pUserObject;
|
||||
}
|
||||
|
||||
void ArmatureAnimation::frameEvent(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex)
|
||||
void ArmatureAnimation::frameEvent(Bone *bone, const std::string& frameEventName, int originFrameIndex, int currentFrameIndex)
|
||||
{
|
||||
if ((_frameEventTarget && _frameEventCallFunc) || _frameEventListener)
|
||||
{
|
||||
|
@ -492,7 +492,7 @@ void ArmatureAnimation::frameEvent(Bone *bone, const char *frameEventName, int o
|
|||
}
|
||||
|
||||
|
||||
void ArmatureAnimation::movementEvent(Armature *armature, MovementEventType movementType, const char *movementID)
|
||||
void ArmatureAnimation::movementEvent(Armature *armature, MovementEventType movementType, const std::string& movementID)
|
||||
{
|
||||
if ((_movementEventTarget && _movementEventCallFunc) || _movementEventListener)
|
||||
{
|
||||
|
|
|
@ -44,8 +44,8 @@ enum MovementEventType
|
|||
class Armature;
|
||||
class Bone;
|
||||
|
||||
typedef void (cocos2d::Object::*SEL_MovementEventCallFunc)(Armature *, MovementEventType, const char *);
|
||||
typedef void (cocos2d::Object::*SEL_FrameEventCallFunc)(Bone *, const char *, int, int);
|
||||
typedef void (cocos2d::Object::*SEL_MovementEventCallFunc)(Armature *, MovementEventType, const std::string&);
|
||||
typedef void (cocos2d::Object::*SEL_FrameEventCallFunc)(Bone *, const std::string&, int, int);
|
||||
|
||||
#define movementEvent_selector(_SELECTOR) (cocostudio::SEL_MovementEventCallFunc)(&_SELECTOR)
|
||||
#define frameEvent_selector(_SELECTOR) (cocostudio::SEL_FrameEventCallFunc)(&_SELECTOR)
|
||||
|
@ -53,7 +53,7 @@ typedef void (cocos2d::Object::*SEL_FrameEventCallFunc)(Bone *, const char *, in
|
|||
struct FrameEvent
|
||||
{
|
||||
Bone *bone;
|
||||
const char *frameEventName;
|
||||
std::string frameEventName;
|
||||
int originFrameIndex;
|
||||
int currentFrameIndex;
|
||||
};
|
||||
|
@ -62,7 +62,7 @@ struct MovementEvent
|
|||
{
|
||||
Armature *armature;
|
||||
MovementEventType movementType;
|
||||
const char *movementID;
|
||||
std::string movementID;
|
||||
};
|
||||
|
||||
class ArmatureAnimation : public ProcessBase
|
||||
|
@ -123,7 +123,7 @@ public:
|
|||
* loop = 0 : this animation is not loop
|
||||
* loop > 0 : this animation is loop
|
||||
*/
|
||||
virtual void play(const char *animationName, int durationTo = -1, int loop = -1);
|
||||
virtual void play(const std::string& animationName, int durationTo = -1, int loop = -1);
|
||||
|
||||
/**
|
||||
* Play animation by index, the other param is the same to play.
|
||||
|
@ -191,8 +191,8 @@ public:
|
|||
*/
|
||||
CC_DEPRECATED_ATTRIBUTE void setFrameEventCallFunc(cocos2d::Object *target, SEL_FrameEventCallFunc callFunc);
|
||||
|
||||
void setMovementEventCallFunc(std::function<void(Armature *armature, MovementEventType movementType, const char *movementID)> listener);
|
||||
void setFrameEventCallFunc(std::function<void(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex)> listener);
|
||||
void setMovementEventCallFunc(std::function<void(Armature *armature, MovementEventType movementType, const std::string& movementID)> listener);
|
||||
void setFrameEventCallFunc(std::function<void(Bone *bone, const std::string& frameEventName, int originFrameIndex, int currentFrameIndex)> listener);
|
||||
|
||||
virtual void setAnimationData(AnimationData *data)
|
||||
{
|
||||
|
@ -254,12 +254,12 @@ protected:
|
|||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
void frameEvent(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex);
|
||||
void frameEvent(Bone *bone, const std::string& frameEventName, int originFrameIndex, int currentFrameIndex);
|
||||
|
||||
/**
|
||||
* Emit a movement event
|
||||
*/
|
||||
void movementEvent(Armature *armature, MovementEventType movementType, const char *movementID);
|
||||
void movementEvent(Armature *armature, MovementEventType movementType, const std::string& movementID);
|
||||
|
||||
void updateMovementList();
|
||||
|
||||
|
@ -319,8 +319,8 @@ protected:
|
|||
cocos2d::Object *_frameEventTarget;
|
||||
|
||||
|
||||
std::function<void(Armature *armature, MovementEventType movementType, const char *movementID)> _movementEventListener;
|
||||
std::function<void(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex)> _frameEventListener;
|
||||
std::function<void(Armature *armature, MovementEventType movementType, const std::string& movementID)> _movementEventListener;
|
||||
std::function<void(Bone *bone, const std::string& frameEventName, int originFrameIndex, int currentFrameIndex)> _frameEventListener;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ bool ArmatureDataManager::init()
|
|||
return bRet;
|
||||
}
|
||||
|
||||
void ArmatureDataManager::removeArmatureFileInfo(const char *configFilePath)
|
||||
void ArmatureDataManager::removeArmatureFileInfo(const std::string& configFilePath)
|
||||
{
|
||||
if (RelativeData *data = getRelativeData(configFilePath))
|
||||
{
|
||||
|
@ -119,7 +119,7 @@ void ArmatureDataManager::removeArmatureFileInfo(const char *configFilePath)
|
|||
}
|
||||
|
||||
|
||||
void ArmatureDataManager::addArmatureData(const char *id, ArmatureData *armatureData, const char *configFilePath)
|
||||
void ArmatureDataManager::addArmatureData(const std::string& id, ArmatureData *armatureData, const std::string& configFilePath)
|
||||
{
|
||||
if (RelativeData *data = getRelativeData(configFilePath))
|
||||
{
|
||||
|
@ -129,19 +129,19 @@ void ArmatureDataManager::addArmatureData(const char *id, ArmatureData *armature
|
|||
_armarureDatas.insert(id, armatureData);
|
||||
}
|
||||
|
||||
ArmatureData *ArmatureDataManager::getArmatureData(const char *id)
|
||||
ArmatureData *ArmatureDataManager::getArmatureData(const std::string& id)
|
||||
{
|
||||
ArmatureData *armatureData = nullptr;
|
||||
armatureData = (ArmatureData *)_armarureDatas.at(id);
|
||||
return armatureData;
|
||||
}
|
||||
|
||||
void ArmatureDataManager::removeArmatureData(const char *id)
|
||||
void ArmatureDataManager::removeArmatureData(const std::string& id)
|
||||
{
|
||||
_armarureDatas.erase(id);
|
||||
}
|
||||
|
||||
void ArmatureDataManager::addAnimationData(const char *id, AnimationData *animationData, const char *configFilePath)
|
||||
void ArmatureDataManager::addAnimationData(const std::string& id, AnimationData *animationData, const std::string& configFilePath)
|
||||
{
|
||||
if (RelativeData *data = getRelativeData(configFilePath))
|
||||
{
|
||||
|
@ -151,19 +151,19 @@ void ArmatureDataManager::addAnimationData(const char *id, AnimationData *animat
|
|||
_animationDatas.insert(id, animationData);
|
||||
}
|
||||
|
||||
AnimationData *ArmatureDataManager::getAnimationData(const char *id)
|
||||
AnimationData *ArmatureDataManager::getAnimationData(const std::string& id)
|
||||
{
|
||||
AnimationData *animationData = nullptr;
|
||||
animationData = (AnimationData *)_animationDatas.at(id);
|
||||
return animationData;
|
||||
}
|
||||
|
||||
void ArmatureDataManager::removeAnimationData(const char *id)
|
||||
void ArmatureDataManager::removeAnimationData(const std::string& id)
|
||||
{
|
||||
_animationDatas.erase(id);
|
||||
}
|
||||
|
||||
void ArmatureDataManager::addTextureData(const char *id, TextureData *textureData, const char *configFilePath)
|
||||
void ArmatureDataManager::addTextureData(const std::string& id, TextureData *textureData, const std::string& configFilePath)
|
||||
{
|
||||
if (RelativeData *data = getRelativeData(configFilePath))
|
||||
{
|
||||
|
@ -174,7 +174,7 @@ void ArmatureDataManager::addTextureData(const char *id, TextureData *textureDat
|
|||
}
|
||||
|
||||
|
||||
TextureData *ArmatureDataManager::getTextureData(const char *id)
|
||||
TextureData *ArmatureDataManager::getTextureData(const std::string& id)
|
||||
{
|
||||
TextureData *textureData = nullptr;
|
||||
textureData = (TextureData *)_textureDatas.at(id);
|
||||
|
@ -182,12 +182,12 @@ TextureData *ArmatureDataManager::getTextureData(const char *id)
|
|||
}
|
||||
|
||||
|
||||
void ArmatureDataManager::removeTextureData(const char *id)
|
||||
void ArmatureDataManager::removeTextureData(const std::string& id)
|
||||
{
|
||||
_textureDatas.erase(id);
|
||||
}
|
||||
|
||||
void ArmatureDataManager::addArmatureFileInfo(const char *configFilePath)
|
||||
void ArmatureDataManager::addArmatureFileInfo(const std::string& configFilePath)
|
||||
{
|
||||
addRelativeData(configFilePath);
|
||||
|
||||
|
@ -195,7 +195,7 @@ void ArmatureDataManager::addArmatureFileInfo(const char *configFilePath)
|
|||
DataReaderHelper::getInstance()->addDataFromFile(configFilePath);
|
||||
}
|
||||
|
||||
void ArmatureDataManager::addArmatureFileInfoAsync(const char *configFilePath, Object *target, SEL_SCHEDULE selector)
|
||||
void ArmatureDataManager::addArmatureFileInfoAsync(const std::string& configFilePath, Object *target, SEL_SCHEDULE selector)
|
||||
{
|
||||
addRelativeData(configFilePath);
|
||||
|
||||
|
@ -203,7 +203,7 @@ void ArmatureDataManager::addArmatureFileInfoAsync(const char *configFilePath, O
|
|||
DataReaderHelper::getInstance()->addDataFromFileAsync("", "", configFilePath, target, selector);
|
||||
}
|
||||
|
||||
void ArmatureDataManager::addArmatureFileInfo(const char *imagePath, const char *plistPath, const char *configFilePath)
|
||||
void ArmatureDataManager::addArmatureFileInfo(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath)
|
||||
{
|
||||
addRelativeData(configFilePath);
|
||||
|
||||
|
@ -212,7 +212,7 @@ void ArmatureDataManager::addArmatureFileInfo(const char *imagePath, const char
|
|||
addSpriteFrameFromFile(plistPath, imagePath);
|
||||
}
|
||||
|
||||
void ArmatureDataManager::addArmatureFileInfoAsync(const char *imagePath, const char *plistPath, const char *configFilePath, Object *target, SEL_SCHEDULE selector)
|
||||
void ArmatureDataManager::addArmatureFileInfoAsync(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath, Object *target, SEL_SCHEDULE selector)
|
||||
{
|
||||
addRelativeData(configFilePath);
|
||||
|
||||
|
@ -221,7 +221,7 @@ void ArmatureDataManager::addArmatureFileInfoAsync(const char *imagePath, const
|
|||
addSpriteFrameFromFile(plistPath, imagePath);
|
||||
}
|
||||
|
||||
void ArmatureDataManager::addSpriteFrameFromFile(const char *plistPath, const char *imagePath, const char *configFilePath)
|
||||
void ArmatureDataManager::addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath, const std::string& configFilePath)
|
||||
{
|
||||
if (RelativeData *data = getRelativeData(configFilePath))
|
||||
{
|
||||
|
@ -249,7 +249,7 @@ const cocos2d::Map<std::string, TextureData*>& ArmatureDataManager::getTextureDa
|
|||
return _textureDatas;
|
||||
}
|
||||
|
||||
void CCArmatureDataManager::addRelativeData(const char *configFilePath)
|
||||
void CCArmatureDataManager::addRelativeData(const std::string& configFilePath)
|
||||
{
|
||||
if (_relativeDatas.find(configFilePath) == _relativeDatas.end())
|
||||
{
|
||||
|
@ -257,7 +257,7 @@ void CCArmatureDataManager::addRelativeData(const char *configFilePath)
|
|||
}
|
||||
}
|
||||
|
||||
RelativeData *CCArmatureDataManager::getRelativeData(const char* configFilePath)
|
||||
RelativeData *CCArmatureDataManager::getRelativeData(const std::string& configFilePath)
|
||||
{
|
||||
return &_relativeDatas[configFilePath];
|
||||
}
|
||||
|
|
|
@ -77,89 +77,89 @@ public:
|
|||
* @param id The id of the armature data
|
||||
* @param armatureData ArmatureData *
|
||||
*/
|
||||
void addArmatureData(const char *id, ArmatureData *armatureData, const char *configFilePath = "");
|
||||
void addArmatureData(const std::string& id, ArmatureData *armatureData, const std::string& configFilePath = "");
|
||||
|
||||
/**
|
||||
* @brief get armature data
|
||||
* @param id the id of the armature data you want to get
|
||||
* @return ArmatureData *
|
||||
*/
|
||||
ArmatureData *getArmatureData(const char *id);
|
||||
ArmatureData *getArmatureData(const std::string& id);
|
||||
|
||||
/**
|
||||
* @brief remove armature data
|
||||
* @param id the id of the armature data you want to get
|
||||
*/
|
||||
void removeArmatureData(const char *id);
|
||||
void removeArmatureData(const std::string& id);
|
||||
|
||||
/**
|
||||
* @brief add animation data
|
||||
* @param id the id of the animation data
|
||||
* @return AnimationData *
|
||||
*/
|
||||
void addAnimationData(const char *id, AnimationData *animationData, const char *configFilePath = "");
|
||||
void addAnimationData(const std::string& id, AnimationData *animationData, const std::string& configFilePath = "");
|
||||
|
||||
/**
|
||||
* @brief get animation data from _animationDatas(Dictionary)
|
||||
* @param id the id of the animation data you want to get
|
||||
* @return AnimationData *
|
||||
*/
|
||||
AnimationData *getAnimationData(const char *id);
|
||||
AnimationData *getAnimationData(const std::string& id);
|
||||
|
||||
/**
|
||||
* @brief remove animation data
|
||||
* @param id the id of the animation data
|
||||
*/
|
||||
void removeAnimationData(const char *id);
|
||||
void removeAnimationData(const std::string& id);
|
||||
|
||||
/**
|
||||
* @brief add texture data
|
||||
* @param id the id of the texture data
|
||||
* @return TextureData *
|
||||
*/
|
||||
void addTextureData(const char *id, TextureData *textureData, const char *configFilePath = "");
|
||||
void addTextureData(const std::string& id, TextureData *textureData, const std::string& configFilePath = "");
|
||||
|
||||
/**
|
||||
* @brief get texture data
|
||||
* @param id the id of the texture data you want to get
|
||||
* @return TextureData *
|
||||
*/
|
||||
TextureData *getTextureData(const char *id);
|
||||
TextureData *getTextureData(const std::string& id);
|
||||
|
||||
/**
|
||||
* @brief remove texture data
|
||||
* @param id the id of the texture data you want to get
|
||||
*/
|
||||
void removeTextureData(const char *id);
|
||||
void removeTextureData(const std::string& id);
|
||||
|
||||
/**
|
||||
* @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager.
|
||||
*/
|
||||
void addArmatureFileInfo(const char *configFilePath);
|
||||
void addArmatureFileInfo(const std::string& configFilePath);
|
||||
|
||||
/**
|
||||
* @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager.
|
||||
* It will load data in a new thread
|
||||
*/
|
||||
void addArmatureFileInfoAsync(const char *configFilePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector);
|
||||
void addArmatureFileInfoAsync(const std::string& configFilePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector);
|
||||
|
||||
/**
|
||||
* @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager.
|
||||
*/
|
||||
void addArmatureFileInfo(const char *imagePath, const char *plistPath, const char *configFilePath);
|
||||
void addArmatureFileInfo(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath);
|
||||
|
||||
/**
|
||||
* @brief Add ArmatureFileInfo, it is managed by ArmatureDataManager.
|
||||
* It will load data in a new thread
|
||||
*/
|
||||
void addArmatureFileInfoAsync(const char *imagePath, const char *plistPath, const char *configFilePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector);
|
||||
void addArmatureFileInfoAsync(const std::string& imagePath, const std::string& plistPath, const std::string& configFilePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector);
|
||||
|
||||
/**
|
||||
* @brief Add sprite frame to CCSpriteFrameCache, it will save display name and it's relative image name
|
||||
*/
|
||||
void addSpriteFrameFromFile(const char *plistPath, const char *imagePath, const char *configFilePath = "");
|
||||
void addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath, const std::string& configFilePath = "");
|
||||
|
||||
virtual void removeArmatureFileInfo(const char *configFilePath);
|
||||
virtual void removeArmatureFileInfo(const std::string& configFilePath);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -173,8 +173,8 @@ public:
|
|||
const cocos2d::Map<std::string, TextureData*>& getTextureDatas() const;
|
||||
|
||||
protected:
|
||||
void addRelativeData(const char* configFilePath);
|
||||
RelativeData *getRelativeData(const char* configFilePath);
|
||||
void addRelativeData(const std::string& configFilePath);
|
||||
RelativeData *getRelativeData(const std::string& configFilePath);
|
||||
private:
|
||||
/**
|
||||
* @brief save amature datas
|
||||
|
|
|
@ -47,7 +47,7 @@ Bone *Bone::create()
|
|||
|
||||
}
|
||||
|
||||
Bone *Bone::create(const char *name)
|
||||
Bone *Bone::create(const std::string& name)
|
||||
{
|
||||
|
||||
Bone *pBone = new Bone();
|
||||
|
@ -101,16 +101,13 @@ bool Bone::init()
|
|||
}
|
||||
|
||||
|
||||
bool Bone::init(const char *name)
|
||||
bool Bone::init(const std::string& name)
|
||||
{
|
||||
bool bRet = false;
|
||||
do
|
||||
{
|
||||
|
||||
if(nullptr != name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
_name = name;
|
||||
|
||||
CC_SAFE_DELETE(_tweenData);
|
||||
_tweenData = new FrameData();
|
||||
|
@ -425,7 +422,7 @@ void Bone::changeDisplayByIndex(int index, bool force)
|
|||
}
|
||||
|
||||
|
||||
void Bone::changeDisplayByName(const char *name, bool force)
|
||||
void Bone::changeDisplayByName(const std::string& name, bool force)
|
||||
{
|
||||
_displayManager->changeDisplayByName(name, force);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public:
|
|||
* @param name If name is not null, then set name to the bone's name
|
||||
* @return A initialized bone which is marked as "autorelease".
|
||||
*/
|
||||
static Bone *create(const char *name);
|
||||
static Bone *create(const std::string& name);
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -72,7 +72,7 @@ public:
|
|||
* Initializes a Bone with the specified name
|
||||
* @param name Bone's name.
|
||||
*/
|
||||
virtual bool init(const char *name);
|
||||
virtual bool init(const std::string& name);
|
||||
|
||||
/**
|
||||
* Add display and use displayData to init the display.
|
||||
|
@ -92,7 +92,7 @@ public:
|
|||
void removeDisplay(int index);
|
||||
|
||||
void changeDisplayByIndex(int index, bool force);
|
||||
void changeDisplayByName(const char *name, bool force);
|
||||
void changeDisplayByName(const std::string& name, bool force);
|
||||
|
||||
/**
|
||||
* Add a child to this bone, and it will let this child call setParent(Bone *parent) function to set self to it's parent
|
||||
|
|
|
@ -59,8 +59,6 @@ static const char *A_MOVEMENT_SCALE = "sc";
|
|||
static const char *A_MOVEMENT_DELAY = "dl";
|
||||
static const char *A_DISPLAY_INDEX = "dI";
|
||||
|
||||
// static const char *A_VERT = "vert";
|
||||
// static const char *A_FRAG = "frag";
|
||||
static const char *A_PLIST = "plist";
|
||||
|
||||
static const char *A_PARENT = "parent";
|
||||
|
@ -73,9 +71,8 @@ static const char *A_EVENT = "evt";
|
|||
static const char *A_SOUND = "sd";
|
||||
static const char *A_SOUND_EFFECT = "sdE";
|
||||
static const char *A_TWEEN_EASING = "twE";
|
||||
//static const char *A_EASING_PARAM_NUMBER = "twEPN";
|
||||
static const char *A_EASING_PARAM = "twEP";
|
||||
//static const char *A_TWEEN_ROTATE = "twR";
|
||||
static const char *A_TWEEN_ROTATE = "twR";
|
||||
static const char *A_IS_ARMATURE = "isArmature";
|
||||
static const char *A_DISPLAY_TYPE = "displayType";
|
||||
static const char *A_MOVEMENT = "mov";
|
||||
|
@ -108,17 +105,12 @@ static const char *A_GREEN_OFFSET = "gM";
|
|||
static const char *A_BLUE_OFFSET = "bM";
|
||||
static const char *A_COLOR_TRANSFORM = "colorTransform";
|
||||
static const char *A_TWEEN_FRAME = "tweenFrame";
|
||||
//static const char *A_ROTATION = "rotation";
|
||||
//static const char *A_USE_COLOR_INFO = "uci";
|
||||
|
||||
|
||||
|
||||
static const char *CONTOUR = "con";
|
||||
static const char *CONTOUR_VERTEX = "con_vt";
|
||||
|
||||
//static const char *MOVEMENT_EVENT_FRAME = "movementEventFrame";
|
||||
//static const char *SOUND_FRAME = "soundFrame";
|
||||
|
||||
|
||||
static const char *FL_NAN = "NaN";
|
||||
|
||||
|
@ -262,14 +254,14 @@ DataReaderHelper::~DataReaderHelper()
|
|||
_dataReaderHelper = nullptr;
|
||||
}
|
||||
|
||||
void DataReaderHelper::addDataFromFile(const char *filePath)
|
||||
void DataReaderHelper::addDataFromFile(const std::string& filePath)
|
||||
{
|
||||
/*
|
||||
* Check if file is already added to ArmatureDataManager, if then return.
|
||||
*/
|
||||
for(unsigned int i = 0; i < _configFileList.size(); i++)
|
||||
{
|
||||
if (_configFileList[i].compare(filePath) == 0)
|
||||
if (_configFileList[i] == filePath)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -295,34 +287,38 @@ void DataReaderHelper::addDataFromFile(const char *filePath)
|
|||
size_t startPos = filePathStr.find_last_of(".");
|
||||
std::string str = &filePathStr[startPos];
|
||||
|
||||
// Read content from file
|
||||
ssize_t size;
|
||||
std::string fullPath = CCFileUtils::getInstance()->fullPathForFilename(filePath);
|
||||
char *pFileContent = (char *)CCFileUtils::getInstance()->getFileData(fullPath.c_str() , "r", &size);
|
||||
unsigned char *pTempContent = (unsigned char *)CCFileUtils::getInstance()->getFileData(fullPath.c_str() , "r", &size);
|
||||
|
||||
std::string contentStr = std::string((const char*)pTempContent, size);
|
||||
|
||||
DataInfo dataInfo;
|
||||
dataInfo.filename = filePathStr;
|
||||
dataInfo.asyncStruct = nullptr;
|
||||
dataInfo.baseFilePath = basefilePath;
|
||||
|
||||
if (str.compare(".xml") == 0)
|
||||
if (str == ".xml")
|
||||
{
|
||||
DataReaderHelper::addDataFromCache(pFileContent, &dataInfo);
|
||||
DataReaderHelper::addDataFromCache(contentStr, &dataInfo);
|
||||
}
|
||||
else if(str.compare(".json") == 0 || str.compare(".ExportJson") == 0)
|
||||
else if(str == ".json" || str == ".ExportJson")
|
||||
{
|
||||
DataReaderHelper::addDataFromJsonCache(pFileContent, &dataInfo);
|
||||
DataReaderHelper::addDataFromJsonCache(contentStr, &dataInfo);
|
||||
}
|
||||
free(pFileContent);
|
||||
|
||||
free(pTempContent);
|
||||
}
|
||||
|
||||
void DataReaderHelper::addDataFromFileAsync(const char *imagePath, const char *plistPath, const char *filePath, Object *target, SEL_SCHEDULE selector)
|
||||
void DataReaderHelper::addDataFromFileAsync(const std::string& imagePath, const std::string& plistPath, const std::string& filePath, Object *target, SEL_SCHEDULE selector)
|
||||
{
|
||||
/*
|
||||
* Check if file is already added to ArmatureDataManager, if then return.
|
||||
*/
|
||||
for(unsigned int i = 0; i < _configFileList.size(); i++)
|
||||
{
|
||||
if (_configFileList[i].compare(filePath) == 0)
|
||||
if (_configFileList[i] == filePath)
|
||||
{
|
||||
if (target && selector)
|
||||
{
|
||||
|
@ -400,11 +396,11 @@ void DataReaderHelper::addDataFromFileAsync(const char *imagePath, const char *p
|
|||
// XXX fileContent is being leaked
|
||||
data->fileContent = (char *)CCFileUtils::getInstance()->getFileData(fullPath.c_str() , "r", &size);
|
||||
|
||||
if (str.compare(".xml") == 0)
|
||||
if (str == ".xml")
|
||||
{
|
||||
data->configType = DragonBone_XML;
|
||||
}
|
||||
else if(str.compare(".json") == 0 || str.compare(".ExportJson") == 0)
|
||||
else if(str == ".json" || str == ".ExportJson")
|
||||
{
|
||||
data->configType = CocoStudio_JSON;
|
||||
}
|
||||
|
@ -478,7 +474,7 @@ void DataReaderHelper::addDataAsyncCallBack(float dt)
|
|||
}
|
||||
|
||||
|
||||
void DataReaderHelper::removeConfigFile(const char *configFile)
|
||||
void DataReaderHelper::removeConfigFile(const std::string& configFile)
|
||||
{
|
||||
std::vector<std::string>::iterator it = _configFileList.end();
|
||||
for (std::vector<std::string>::iterator i = _configFileList.begin(); i != _configFileList.end(); i++)
|
||||
|
@ -497,10 +493,10 @@ void DataReaderHelper::removeConfigFile(const char *configFile)
|
|||
|
||||
|
||||
|
||||
void DataReaderHelper::addDataFromCache(const char *pFileContent, DataInfo *dataInfo)
|
||||
void DataReaderHelper::addDataFromCache(const std::string& pFileContent, DataInfo *dataInfo)
|
||||
{
|
||||
tinyxml2::XMLDocument document;
|
||||
document.Parse(pFileContent);
|
||||
document.Parse(pFileContent.c_str());
|
||||
|
||||
tinyxml2::XMLElement *root = document.RootElement();
|
||||
CCASSERT(root, "XML error or XML is empty.");
|
||||
|
@ -600,7 +596,7 @@ ArmatureData *DataReaderHelper::decodeArmature(tinyxml2::XMLElement *armatureXML
|
|||
std::string parentNameStr = parentName;
|
||||
while (parentXML)
|
||||
{
|
||||
if (parentNameStr.compare(parentXML->Attribute(A_NAME)) == 0)
|
||||
if (parentNameStr == parentXML->Attribute(A_NAME))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -745,7 +741,7 @@ MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML
|
|||
if(_easing != nullptr)
|
||||
{
|
||||
std::string str = _easing;
|
||||
if(str.compare(FL_NAN) != 0)
|
||||
if(str != FL_NAN)
|
||||
{
|
||||
if( movementXML->QueryIntAttribute(A_TWEEN_EASING, &(tweenEasing)) == tinyxml2::XML_SUCCESS)
|
||||
{
|
||||
|
@ -782,7 +778,7 @@ MovementData *DataReaderHelper::decodeMovement(tinyxml2::XMLElement *movementXML
|
|||
|
||||
while (parentXml)
|
||||
{
|
||||
if (parentName.compare(parentXml->Attribute(A_NAME)) == 0)
|
||||
if (parentName == parentXml->Attribute(A_NAME))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -921,8 +917,8 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov
|
|||
|
||||
FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxml2::XMLElement *parentFrameXml, BoneData *boneData, DataInfo *dataInfo)
|
||||
{
|
||||
float x, y, scale_x, scale_y, skew_x, skew_y = 0;
|
||||
int duration, displayIndex, zOrder, tweenEasing, blendType = 0;
|
||||
float x = 0, y = 0, scale_x = 0, scale_y = 0, skew_x = 0, skew_y = 0, tweenRotate = 0;
|
||||
int duration = 0, displayIndex = 0, zOrder = 0, tweenEasing = 0, blendType = 0;
|
||||
|
||||
FrameData *frameData = new FrameData();
|
||||
|
||||
|
@ -1005,6 +1001,10 @@ FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxm
|
|||
{
|
||||
frameData->zOrder = zOrder;
|
||||
}
|
||||
if( frameXML->QueryFloatAttribute(A_TWEEN_ROTATE, &tweenRotate) == tinyxml2::XML_SUCCESS )
|
||||
{
|
||||
frameData->tweenRotate = tweenRotate;
|
||||
}
|
||||
if ( frameXML->QueryIntAttribute(A_BLEND_TYPE, &blendType) == tinyxml2::XML_SUCCESS )
|
||||
{
|
||||
switch (blendType)
|
||||
|
@ -1070,7 +1070,7 @@ FrameData *DataReaderHelper::decodeFrame(tinyxml2::XMLElement *frameXML, tinyxm
|
|||
if(_easing != nullptr)
|
||||
{
|
||||
std::string str = _easing;
|
||||
if(str.compare(FL_NAN) != 0)
|
||||
if(str != FL_NAN)
|
||||
{
|
||||
if( frameXML->QueryIntAttribute(A_TWEEN_EASING, &(tweenEasing)) == tinyxml2::XML_SUCCESS)
|
||||
{
|
||||
|
@ -1184,10 +1184,10 @@ ContourData *DataReaderHelper::decodeContour(tinyxml2::XMLElement *contourXML, D
|
|||
|
||||
|
||||
|
||||
void DataReaderHelper::addDataFromJsonCache(const char *fileContent, DataInfo *dataInfo)
|
||||
void DataReaderHelper::addDataFromJsonCache(const std::string& fileContent, DataInfo *dataInfo)
|
||||
{
|
||||
JsonDictionary json;
|
||||
json.initWithDescription(fileContent);
|
||||
json.initWithDescription(fileContent.c_str());
|
||||
|
||||
dataInfo->contentScale = json.getItemFloatValue(CONTENT_SCALE, 1);
|
||||
|
||||
|
|
|
@ -108,12 +108,12 @@ public:
|
|||
*/
|
||||
~DataReaderHelper();
|
||||
|
||||
void addDataFromFile(const char *filePath);
|
||||
void addDataFromFileAsync(const char *imagePath, const char *plistPath, const char *filePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector);
|
||||
void addDataFromFile(const std::string& filePath);
|
||||
void addDataFromFileAsync(const std::string& imagePath, const std::string& plistPath, const std::string& filePath, cocos2d::Object *target, cocos2d::SEL_SCHEDULE selector);
|
||||
|
||||
void addDataAsyncCallBack(float dt);
|
||||
|
||||
void removeConfigFile(const char *configFile);
|
||||
void removeConfigFile(const std::string& configFile);
|
||||
public:
|
||||
|
||||
/**
|
||||
|
@ -122,7 +122,7 @@ public:
|
|||
*
|
||||
* @param xmlPath The cache of the xml
|
||||
*/
|
||||
static void addDataFromCache(const char *pFileContent, DataInfo *dataInfo = nullptr);
|
||||
static void addDataFromCache(const std::string& pFileContent, DataInfo *dataInfo = nullptr);
|
||||
|
||||
|
||||
|
||||
|
@ -154,7 +154,7 @@ public:
|
|||
static ContourData *decodeContour(tinyxml2::XMLElement *contourXML, DataInfo *dataInfo);
|
||||
|
||||
public:
|
||||
static void addDataFromJsonCache(const char *fileContent, DataInfo *dataInfo = nullptr);
|
||||
static void addDataFromJsonCache(const std::string& fileContent, DataInfo *dataInfo = nullptr);
|
||||
|
||||
static ArmatureData *decodeArmature(JsonDictionary &json, DataInfo *dataInfo);
|
||||
static BoneData *decodeBone(JsonDictionary &json, DataInfo *dataInfo);
|
||||
|
|
|
@ -123,8 +123,8 @@ void BaseData::subtract(BaseData *from, BaseData *to, bool limit)
|
|||
|
||||
if (to->tweenRotate)
|
||||
{
|
||||
skewX += to->tweenRotate;
|
||||
skewY -= to->tweenRotate;
|
||||
skewX += to->tweenRotate * M_PI * 2;
|
||||
skewY -= to->tweenRotate * M_PI * 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ Color4B BaseData::getColor()
|
|||
return Color4B(r, g, b, a);
|
||||
}
|
||||
|
||||
const char *DisplayData::changeDisplayToTexture(const char *displayName)
|
||||
const std::string& DisplayData::changeDisplayToTexture(const std::string& displayName)
|
||||
{
|
||||
// remove .xxx
|
||||
std::string textureName = displayName;
|
||||
|
@ -241,7 +241,7 @@ void ArmatureData::addBoneData(BoneData *boneData)
|
|||
boneDataDic.insert(boneData->name, boneData);
|
||||
}
|
||||
|
||||
BoneData *ArmatureData::getBoneData(const char *boneName)
|
||||
BoneData *ArmatureData::getBoneData(const std::string& boneName)
|
||||
{
|
||||
return static_cast<BoneData*>(boneDataDic.at(boneName));
|
||||
}
|
||||
|
@ -343,7 +343,7 @@ void MovementData::addMovementBoneData(MovementBoneData *movBoneData)
|
|||
movBoneDataDic.insert(movBoneData->name, movBoneData);
|
||||
}
|
||||
|
||||
MovementBoneData *MovementData::getMovementBoneData(const char *boneName)
|
||||
MovementBoneData *MovementData::getMovementBoneData(const std::string& boneName)
|
||||
{
|
||||
return movBoneDataDic.at(boneName);
|
||||
}
|
||||
|
@ -364,7 +364,7 @@ void AnimationData::addMovement(MovementData *movData)
|
|||
movementNames.push_back(movData->name);
|
||||
}
|
||||
|
||||
MovementData *AnimationData::getMovement(const char *movementName)
|
||||
MovementData *AnimationData::getMovement(const std::string& movementName)
|
||||
{
|
||||
return movementDataDic.at(movementName);
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ class DisplayData : public cocos2d::Object
|
|||
public:
|
||||
CC_CREATE_NO_PARAM_NO_INIT(DisplayData)
|
||||
|
||||
static const char *changeDisplayToTexture(const char *displayName);
|
||||
static const std::string& changeDisplayToTexture(const std::string& displayName);
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
|
@ -279,7 +279,7 @@ public:
|
|||
|
||||
bool init();
|
||||
void addBoneData(BoneData *boneData);
|
||||
BoneData *getBoneData(const char *boneName);
|
||||
BoneData *getBoneData(const std::string& boneName);
|
||||
public:
|
||||
std::string name;
|
||||
cocos2d::Map<std::string, BoneData*> boneDataDic;
|
||||
|
@ -403,7 +403,7 @@ public:
|
|||
~MovementData(void);
|
||||
|
||||
void addMovementBoneData(MovementBoneData *movBoneData);
|
||||
MovementBoneData *getMovementBoneData(const char *boneName);
|
||||
MovementBoneData *getMovementBoneData(const std::string& boneName);
|
||||
public:
|
||||
std::string name;
|
||||
int duration; //! the frames this movement will last
|
||||
|
@ -435,7 +435,7 @@ public:
|
|||
|
||||
/**
|
||||
* @brief save movment bone data
|
||||
* @key const char *
|
||||
* @key const std::string&
|
||||
* @value MovementBoneData *
|
||||
*/
|
||||
cocos2d::Map<std::string, MovementBoneData*> movBoneDataDic;
|
||||
|
@ -465,7 +465,7 @@ public:
|
|||
~AnimationData(void);
|
||||
|
||||
void addMovement(MovementData *movData);
|
||||
MovementData *getMovement(const char *movementName);
|
||||
MovementData *getMovement(const std::string& movementName);
|
||||
ssize_t getMovementCount();
|
||||
public:
|
||||
std::string name;
|
||||
|
|
|
@ -243,7 +243,7 @@ void DisplayManager::changeDisplayByIndex(int index, bool force)
|
|||
setCurrentDecorativeDisplay(decoDisplay);
|
||||
}
|
||||
|
||||
void CCDisplayManager::changeDisplayByName(const char *name, bool force)
|
||||
void CCDisplayManager::changeDisplayByName(const std::string& name, bool force)
|
||||
{
|
||||
for (int i = 0; i<_decoDisplayList.size(); i++)
|
||||
{
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
*/
|
||||
void changeDisplayByIndex(int index, bool force);
|
||||
|
||||
void changeDisplayByName(const char *name, bool force);
|
||||
void changeDisplayByName(const std::string& name, bool force);
|
||||
|
||||
cocos2d::Node *getDisplayRenderNode() const;
|
||||
DisplayType getDisplayRenderNodeType() const;
|
||||
|
|
|
@ -51,7 +51,7 @@ Skin *Skin::create()
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Skin *Skin::createWithSpriteFrameName(const char *pszSpriteFrameName)
|
||||
Skin *Skin::createWithSpriteFrameName(const std::string& pszSpriteFrameName)
|
||||
{
|
||||
Skin *skin = new Skin();
|
||||
if(skin && skin->initWithSpriteFrameName(pszSpriteFrameName))
|
||||
|
@ -63,7 +63,7 @@ Skin *Skin::createWithSpriteFrameName(const char *pszSpriteFrameName)
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
Skin *Skin::create(const char *pszFileName)
|
||||
Skin *Skin::create(const std::string& pszFileName)
|
||||
{
|
||||
Skin *skin = new Skin();
|
||||
if(skin && skin->initWithFile(pszFileName))
|
||||
|
|
|
@ -34,8 +34,8 @@ class Skin : public cocos2d::Sprite
|
|||
{
|
||||
public:
|
||||
static Skin *create();
|
||||
static Skin *createWithSpriteFrameName(const char *pszSpriteFrameName);
|
||||
static Skin *create(const char *pszFileName);
|
||||
static Skin *createWithSpriteFrameName(const std::string& pszSpriteFrameName);
|
||||
static Skin *create(const std::string& pszFileName);
|
||||
public:
|
||||
/**
|
||||
* @js ctor
|
||||
|
|
|
@ -47,7 +47,7 @@ void SpriteFrameCacheHelper::purge()
|
|||
_spriteFrameCacheHelper = nullptr;
|
||||
}
|
||||
|
||||
void SpriteFrameCacheHelper::addSpriteFrameFromFile(const char *plistPath, const char *imagePath)
|
||||
void SpriteFrameCacheHelper::addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath)
|
||||
{
|
||||
CCSpriteFrameCache::getInstance()->addSpriteFramesWithFile(plistPath, imagePath);
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
/**
|
||||
* @brief Add sprite frame to CCSpriteFrameCache, it will save display name and it's relative image name
|
||||
*/
|
||||
void addSpriteFrameFromFile(const char *plistPath, const char *imagePath);
|
||||
void addSpriteFrameFromFile(const std::string& plistPath, const std::string& imagePath);
|
||||
|
||||
private:
|
||||
SpriteFrameCacheHelper();
|
||||
|
|
|
@ -535,20 +535,18 @@ std::string TestAnimationEvent::title() const
|
|||
{
|
||||
return "Test Armature Animation Event";
|
||||
}
|
||||
void TestAnimationEvent::animationEvent(Armature *armature, MovementEventType movementType, const char *movementID)
|
||||
void TestAnimationEvent::animationEvent(Armature *armature, MovementEventType movementType, const std::string& movementID)
|
||||
{
|
||||
std::string id = movementID;
|
||||
|
||||
if (movementType == LOOP_COMPLETE)
|
||||
{
|
||||
if (id.compare("Fire") == 0)
|
||||
if (movementID == "Fire")
|
||||
{
|
||||
ActionInterval *actionToRight = MoveTo::create(2, Point(VisibleRect::right().x - 50, VisibleRect::right().y));
|
||||
armature->stopAllActions();
|
||||
armature->runAction(Sequence::create(actionToRight, CallFunc::create( CC_CALLBACK_0(TestAnimationEvent::callback1, this)), nullptr));
|
||||
armature->getAnimation()->play("Walk");
|
||||
}
|
||||
else if (id.compare("FireMax") == 0)
|
||||
else if (movementID == "FireMax")
|
||||
{
|
||||
ActionInterval *actionToLeft = MoveTo::create(2, Point(VisibleRect::left().x + 50, VisibleRect::left().y));
|
||||
armature->stopAllActions();
|
||||
|
@ -596,9 +594,9 @@ std::string TestFrameEvent::title() const
|
|||
{
|
||||
return "Test Frame Event";
|
||||
}
|
||||
void TestFrameEvent::onFrameEvent(Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex)
|
||||
void TestFrameEvent::onFrameEvent(Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex)
|
||||
{
|
||||
CCLOG("(%s) emit a frame event (%s) at frame index (%d).", bone->getName().c_str(), evt, currentFrameIndex);
|
||||
CCLOG("(%s) emit a frame event (%s) at frame index (%d).", bone->getName().c_str(), evt.c_str(), currentFrameIndex);
|
||||
|
||||
if (!_gridNode->getActionByTag(FRAME_EVENT_ACTION_TAG) || _gridNode->getActionByTag(FRAME_EVENT_ACTION_TAG)->isDone())
|
||||
{
|
||||
|
@ -778,9 +776,9 @@ std::string TestColliderDetector::title() const
|
|||
{
|
||||
return "Test Collider Detector";
|
||||
}
|
||||
void TestColliderDetector::onFrameEvent(Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex)
|
||||
void TestColliderDetector::onFrameEvent(Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex)
|
||||
{
|
||||
CCLOG("(%s) emit a frame event (%s) at frame index (%d).", bone->getName().c_str(), evt, currentFrameIndex);
|
||||
CCLOG("(%s) emit a frame event (%s) at frame index (%d).", bone->getName().c_str(), evt.c_str(), currentFrameIndex);
|
||||
|
||||
/*
|
||||
* originFrameIndex is the frame index editted in Action Editor
|
||||
|
|
|
@ -153,7 +153,7 @@ public:
|
|||
|
||||
virtual void onEnter();
|
||||
virtual std::string title() const override;
|
||||
void animationEvent(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const char *movementID);
|
||||
void animationEvent(cocostudio::Armature *armature, cocostudio::MovementEventType movementType, const std::string& movementID);
|
||||
void callback1();
|
||||
void callback2();
|
||||
|
||||
|
@ -166,7 +166,7 @@ class TestFrameEvent : public ArmatureTestLayer
|
|||
public:
|
||||
virtual void onEnter();
|
||||
virtual std::string title() const override;
|
||||
void onFrameEvent(cocostudio::Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex);
|
||||
void onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex);
|
||||
void checkAction(float dt);
|
||||
protected:
|
||||
NodeGrid* _gridNode;
|
||||
|
@ -215,7 +215,7 @@ public:
|
|||
virtual void draw();
|
||||
virtual void update(float delta);
|
||||
|
||||
void onFrameEvent(cocostudio::Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex);
|
||||
void onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex);
|
||||
|
||||
void initWorld();
|
||||
|
||||
|
@ -273,7 +273,7 @@ public:
|
|||
virtual void update(float delta);
|
||||
virtual void draw();
|
||||
|
||||
void onFrameEvent(cocostudio::Bone *bone, const char *evt, int originFrameIndex, int currentFrameIndex);
|
||||
void onFrameEvent(cocostudio::Bone *bone, const std::string& evt, int originFrameIndex, int currentFrameIndex);
|
||||
|
||||
void initWorld() {};
|
||||
cocostudio::Armature *armature;
|
||||
|
|
Loading…
Reference in New Issue