mirror of https://github.com/axmolengine/axmol.git
Merge pull request #4165 from 2youyouo2/develop
[ci skip]update armature
This commit is contained in:
commit
8d79e67ecf
|
@ -56,6 +56,7 @@ ArmatureAnimation::ArmatureAnimation()
|
|||
, _toIndex(0)
|
||||
, _tweenList(nullptr)
|
||||
, _ignoreFrameEvent(false)
|
||||
, _userObject(nullptr)
|
||||
|
||||
, _movementEventCallFunc(nullptr)
|
||||
, _frameEventCallFunc(nullptr)
|
||||
|
@ -70,8 +71,7 @@ ArmatureAnimation::~ArmatureAnimation(void)
|
|||
CC_SAFE_RELEASE_NULL(_tweenList);
|
||||
CC_SAFE_RELEASE_NULL(_animationData);
|
||||
|
||||
CC_SAFE_RELEASE_NULL(_movementEventTarget);
|
||||
CC_SAFE_RELEASE_NULL(_frameEventTarget);
|
||||
CC_SAFE_RELEASE_NULL(_userObject);
|
||||
}
|
||||
|
||||
bool ArmatureAnimation::init(Armature *armature)
|
||||
|
@ -208,7 +208,7 @@ void ArmatureAnimation::play(const char *animationName, int durationTo, int dura
|
|||
loop = (loop < 0) ? _movementData->loop : loop;
|
||||
|
||||
|
||||
ProcessBase::play((void *)animationName, durationTo, durationTween, loop, tweenEasing);
|
||||
ProcessBase::play(durationTo, durationTween, loop, tweenEasing);
|
||||
|
||||
|
||||
if (_rawDuration == 0)
|
||||
|
@ -423,26 +423,23 @@ std::string ArmatureAnimation::getCurrentMovementID() const
|
|||
|
||||
void ArmatureAnimation::setMovementEventCallFunc(Object *target, SEL_MovementEventCallFunc callFunc)
|
||||
{
|
||||
if (target != _movementEventTarget)
|
||||
{
|
||||
CC_SAFE_RETAIN(target);
|
||||
CC_SAFE_RELEASE_NULL(_movementEventTarget);
|
||||
_movementEventTarget = target;
|
||||
}
|
||||
_movementEventTarget = target;
|
||||
_movementEventCallFunc = callFunc;
|
||||
}
|
||||
|
||||
void ArmatureAnimation::setFrameEventCallFunc(Object *target, SEL_FrameEventCallFunc callFunc)
|
||||
{
|
||||
if (target != _frameEventTarget)
|
||||
{
|
||||
CC_SAFE_RETAIN(target);
|
||||
CC_SAFE_RELEASE_NULL(_frameEventTarget);
|
||||
_frameEventTarget = target;
|
||||
}
|
||||
_frameEventTarget = target;
|
||||
_frameEventCallFunc = callFunc;
|
||||
}
|
||||
|
||||
void ArmatureAnimation::setUserObject(Object *pUserObject)
|
||||
{
|
||||
CC_SAFE_RETAIN(pUserObject);
|
||||
CC_SAFE_RELEASE(_userObject);
|
||||
_userObject = pUserObject;
|
||||
}
|
||||
|
||||
void ArmatureAnimation::frameEvent(Bone *bone, const char *frameEventName, int originFrameIndex, int currentFrameIndex)
|
||||
{
|
||||
if (_frameEventTarget && _frameEventCallFunc)
|
||||
|
|
|
@ -100,6 +100,7 @@ public:
|
|||
//! The animation update speed
|
||||
virtual void setAnimationInternal(float animationInternal);
|
||||
|
||||
using ProcessBase::play;
|
||||
/**
|
||||
* Play animation by animation name.
|
||||
*
|
||||
|
@ -202,6 +203,35 @@ public:
|
|||
}
|
||||
}
|
||||
virtual AnimationData *getAnimationData() const { return _animationData; }
|
||||
|
||||
|
||||
/**
|
||||
* Returns a user assigned Object
|
||||
*
|
||||
* Similar to userData, but instead of holding a void* it holds an object
|
||||
*
|
||||
* @return A user assigned Object
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual Object* getUserObject() { return _userObject; }
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
virtual const Object* getUserObject() const { return _userObject; }
|
||||
|
||||
/**
|
||||
* Returns a user assigned Object
|
||||
*
|
||||
* Similar to UserData, but instead of holding a void* it holds an object.
|
||||
* The UserObject will be retained once in this method,
|
||||
* and the previous UserObject (if existed) will be relese.
|
||||
* The UserObject will be released in Node's destructure.
|
||||
*
|
||||
* @param userObject A user assigned Object
|
||||
*/
|
||||
virtual void setUserObject(Object *userObject);
|
||||
protected:
|
||||
|
||||
/**
|
||||
|
@ -242,6 +272,8 @@ protected:
|
|||
bool _ignoreFrameEvent;
|
||||
|
||||
std::queue<FrameEvent*> _frameEventQueue;
|
||||
|
||||
cocos2d::Object *_userObject;
|
||||
protected:
|
||||
/**
|
||||
* MovementEvent CallFunc.
|
||||
|
|
|
@ -112,6 +112,7 @@ public:
|
|||
*/
|
||||
Bone *getParentBone();
|
||||
|
||||
using Node::removeFromParent;
|
||||
/**
|
||||
* Remove itself from its parent.
|
||||
* @param recursion whether or not to remove childBone's display
|
||||
|
|
|
@ -594,10 +594,10 @@ ArmatureData *DataReaderHelper::decodeArmature(tinyxml2::XMLElement *armatureXML
|
|||
if (parentName)
|
||||
{
|
||||
parentXML = armatureXML->FirstChildElement(BONE);
|
||||
std::string name = parentName;
|
||||
std::string parentNameStr = parentName;
|
||||
while (parentXML)
|
||||
{
|
||||
if (name.compare(parentXML->Attribute(A_NAME)) == 0)
|
||||
if (parentNameStr.compare(parentXML->Attribute(A_NAME)) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -822,7 +822,7 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov
|
|||
}
|
||||
|
||||
int length = 0;
|
||||
int i = 0;
|
||||
int index = 0;
|
||||
int parentTotalDuration = 0;
|
||||
int currentDuration = 0;
|
||||
|
||||
|
@ -863,13 +863,12 @@ MovementBoneData *DataReaderHelper::decodeMovementBone(tinyxml2::XMLElement *mov
|
|||
/*
|
||||
* in this loop we get the corresponding parent frame xml
|
||||
*/
|
||||
while(i < length && (parentFrameXML ? (totalDuration < parentTotalDuration || totalDuration >= parentTotalDuration + currentDuration) : true))
|
||||
while(index < length && (parentFrameXML ? (totalDuration < parentTotalDuration || totalDuration >= parentTotalDuration + currentDuration) : true))
|
||||
{
|
||||
parentFrameXML = parentXmlList[i];
|
||||
parentFrameXML = parentXmlList[index];
|
||||
parentTotalDuration += currentDuration;
|
||||
parentFrameXML->QueryIntAttribute(A_DURATION, ¤tDuration);
|
||||
i++;
|
||||
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -163,10 +163,8 @@ public:
|
|||
*/
|
||||
virtual ~SpriteDisplayData();
|
||||
|
||||
inline void setParam(const char *displayName)
|
||||
{
|
||||
this->displayName = displayName;
|
||||
}
|
||||
void setParam(const char *pszDisplayName) { this->displayName = pszDisplayName; }
|
||||
|
||||
void copy(SpriteDisplayData *displayData);
|
||||
public:
|
||||
/**
|
||||
|
@ -197,10 +195,7 @@ public:
|
|||
*/
|
||||
virtual ~ArmatureDisplayData();
|
||||
|
||||
inline void setParam(const char *displayName)
|
||||
{
|
||||
this->displayName = displayName;
|
||||
}
|
||||
void setParam(const char *pszDisplayName) { this->displayName = pszDisplayName; }
|
||||
void copy(ArmatureDisplayData *displayData);
|
||||
public:
|
||||
/**
|
||||
|
@ -230,10 +225,7 @@ public:
|
|||
*/
|
||||
virtual ~ParticleDisplayData() {};
|
||||
|
||||
void setParam(const char *plist)
|
||||
{
|
||||
this->plist = plist;
|
||||
}
|
||||
void setParam(const char *pszPlistName) { this->plist = pszPlistName; }
|
||||
|
||||
void copy(ParticleDisplayData *displayData);
|
||||
public:
|
||||
|
@ -478,10 +470,10 @@ public:
|
|||
|
||||
struct ContourVertex2 : public cocos2d::Object
|
||||
{
|
||||
ContourVertex2(float x, float y)
|
||||
ContourVertex2(float xx, float yy)
|
||||
{
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
this->x = xx;
|
||||
this->y = yy;
|
||||
}
|
||||
|
||||
float x;
|
||||
|
|
|
@ -142,8 +142,26 @@ void DisplayManager::addDisplay(Node *display, int index)
|
|||
}
|
||||
else
|
||||
{
|
||||
BaseData baseData;
|
||||
skin->setSkinData(baseData);
|
||||
bool find = false;
|
||||
|
||||
for (int i = _decoDisplayList->count()-2; i>=0; i--)
|
||||
{
|
||||
DecorativeDisplay *dd = static_cast<DecorativeDisplay*>(_decoDisplayList->getObjectAtIndex(i));
|
||||
SpriteDisplayData *sdd = static_cast<SpriteDisplayData*>(dd->getDisplayData());
|
||||
if (sdd)
|
||||
{
|
||||
find = true;
|
||||
skin->setSkinData(sdd->skinData);
|
||||
static_cast<SpriteDisplayData*>(displayData)->skinData = sdd->skinData;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!find)
|
||||
{
|
||||
BaseData baseData;
|
||||
skin->setSkinData(baseData);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (dynamic_cast<ParticleSystemQuad *>(display))
|
||||
|
|
|
@ -77,7 +77,7 @@ void ProcessBase::stop()
|
|||
_currentPercent = 0;
|
||||
}
|
||||
|
||||
void ProcessBase::play(void *animation, int durationTo, int durationTween, int loop, int tweenEasing)
|
||||
void ProcessBase::play(int durationTo, int durationTween, int loop, int tweenEasing)
|
||||
{
|
||||
_isComplete = false;
|
||||
_isPause = false;
|
||||
|
|
|
@ -63,7 +63,6 @@ public:
|
|||
/**
|
||||
* Play animation by animation name.
|
||||
*
|
||||
* @param animation It will not used in the ProcessBase Class
|
||||
* @param durationTo The frames between two animation changing-over.
|
||||
* It's meaning is changing to this animation need how many frames
|
||||
*
|
||||
|
@ -88,7 +87,7 @@ public:
|
|||
* 2 : fade in and out
|
||||
*
|
||||
*/
|
||||
virtual void play(void *animation, int durationTo, int durationTween, int loop, int tweenEasing);
|
||||
virtual void play(int durationTo, int durationTween, int loop, int tweenEasing);
|
||||
|
||||
/**
|
||||
* Pause the Process
|
||||
|
|
|
@ -98,7 +98,7 @@ bool Tween::init(Bone *bone)
|
|||
|
||||
void Tween::play(MovementBoneData *movementBoneData, int durationTo, int durationTween, int loop, int tweenEasing)
|
||||
{
|
||||
ProcessBase::play(nullptr, durationTo, durationTween, loop, tweenEasing);
|
||||
ProcessBase::play(durationTo, durationTween, loop, tweenEasing);
|
||||
|
||||
if (loop)
|
||||
{
|
||||
|
|
|
@ -59,6 +59,7 @@ public:
|
|||
*/
|
||||
virtual bool init(Bone *bone);
|
||||
|
||||
using ProcessBase::play;
|
||||
/**
|
||||
* Start the Process
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue