mirror of https://github.com/axmolengine/axmol.git
update
This commit is contained in:
parent
58550a834c
commit
6fc0eaf5b1
|
@ -413,6 +413,15 @@ void CCArmature::updateOffsetPoint()
|
|||
}
|
||||
}
|
||||
|
||||
void CCArmature::setAnimation(CCArmatureAnimation *animation)
|
||||
{
|
||||
m_pAnimation = animation;
|
||||
}
|
||||
|
||||
CCArmatureAnimation *CCArmature::getAnimation()
|
||||
{
|
||||
return m_pAnimation;
|
||||
}
|
||||
|
||||
void CCArmature::update(float dt)
|
||||
{
|
||||
|
|
|
@ -123,6 +123,8 @@ public:
|
|||
inline void setBlendFunc(ccBlendFunc blendFunc) { m_sBlendFunc = blendFunc; }
|
||||
inline ccBlendFunc getBlendFunc(void) { return m_sBlendFunc; }
|
||||
|
||||
virtual void setAnimation(CCArmatureAnimation *animation);
|
||||
virtual CCArmatureAnimation *getAnimation();
|
||||
protected:
|
||||
|
||||
/*
|
||||
|
@ -131,8 +133,6 @@ protected:
|
|||
CCBone *createBone(const char *boneName );
|
||||
|
||||
|
||||
CC_SYNTHESIZE_RETAIN(CCArmatureAnimation *, m_pAnimation, Animation);
|
||||
|
||||
CC_SYNTHESIZE(CCArmatureData *, m_pArmatureData, ArmatureData);
|
||||
|
||||
CC_SYNTHESIZE(CCBatchNode*, m_pBatchNode, BatchNode);
|
||||
|
@ -152,6 +152,8 @@ protected:
|
|||
ccBlendFunc m_sBlendFunc; //! It's required for CCTextureProtocol inheritance
|
||||
|
||||
CCPoint m_pOffsetPoint;
|
||||
|
||||
CCArmatureAnimation *m_pAnimation;
|
||||
};
|
||||
|
||||
NS_CC_EXT_END
|
||||
|
|
|
@ -104,7 +104,7 @@ void CCTween::play(CCMovementBoneData *movementBoneData, int durationTo, int dur
|
|||
m_pCurrentKeyFrame = NULL;
|
||||
|
||||
m_iTotalDuration = 0;
|
||||
betweenDuration = 0;
|
||||
m_BetweenDuration = 0;
|
||||
m_iToIndex = 0;
|
||||
|
||||
bool difMovement = movementBoneData != m_pMovementBoneData;
|
||||
|
@ -200,7 +200,7 @@ void CCTween::updateHandler()
|
|||
m_iNextFrameIndex = m_iDurationTween;
|
||||
m_fCurrentFrame = m_fCurrentPercent * m_iNextFrameIndex;
|
||||
m_iTotalDuration = 0;
|
||||
betweenDuration = 0;
|
||||
m_BetweenDuration = 0;
|
||||
m_iToIndex = 0;
|
||||
break;
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ void CCTween::updateHandler()
|
|||
}
|
||||
|
||||
m_iTotalDuration = 0;
|
||||
betweenDuration = 0;
|
||||
m_BetweenDuration = 0;
|
||||
m_iToIndex = 0;
|
||||
}
|
||||
break;
|
||||
|
@ -243,7 +243,7 @@ void CCTween::updateHandler()
|
|||
m_fCurrentFrame = fmodf(m_fCurrentFrame, m_iNextFrameIndex);
|
||||
|
||||
m_iTotalDuration = 0;
|
||||
betweenDuration = 0;
|
||||
m_BetweenDuration = 0;
|
||||
m_iToIndex = 0;
|
||||
}
|
||||
break;
|
||||
|
@ -375,7 +375,7 @@ float CCTween::updateFrameData(float currentPrecent, bool activeFrame)
|
|||
bool isListEnd;
|
||||
|
||||
//! If play to current frame's front or back, then find current frame again
|
||||
if (playedTime >= m_iTotalDuration || playedTime < m_iTotalDuration - betweenDuration)
|
||||
if (playedTime >= m_iTotalDuration || playedTime < m_iTotalDuration - m_BetweenDuration)
|
||||
{
|
||||
/*
|
||||
* Get frame length, if m_iToIndex >= _length, then set m_iToIndex to 0, start anew.
|
||||
|
@ -384,8 +384,8 @@ float CCTween::updateFrameData(float currentPrecent, bool activeFrame)
|
|||
int length = m_pMovementBoneData->frameList.count();
|
||||
do
|
||||
{
|
||||
betweenDuration = m_pMovementBoneData->getFrameData(m_iToIndex)->duration;
|
||||
m_iTotalDuration += betweenDuration;
|
||||
m_BetweenDuration = m_pMovementBoneData->getFrameData(m_iToIndex)->duration;
|
||||
m_iTotalDuration += m_BetweenDuration;
|
||||
m_iFromIndex = m_iToIndex;
|
||||
|
||||
if (++m_iToIndex >= length)
|
||||
|
@ -413,7 +413,7 @@ float CCTween::updateFrameData(float currentPrecent, bool activeFrame)
|
|||
setBetween(from, to);
|
||||
|
||||
}
|
||||
currentPrecent = 1 - (m_iTotalDuration - playedTime) / (float)betweenDuration;
|
||||
currentPrecent = 1 - (m_iTotalDuration - playedTime) / (float)m_BetweenDuration;
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -130,7 +130,7 @@ protected:
|
|||
|
||||
CCTweenType m_eFrameTweenEasing; //! Dedermine which tween effect current frame use
|
||||
|
||||
int betweenDuration; //! Current key frame will last betweenDuration frames
|
||||
int m_BetweenDuration; //! Current key frame will last m_BetweenDuration frames
|
||||
int m_iTotalDuration;
|
||||
|
||||
|
||||
|
|
|
@ -122,6 +122,19 @@ void CCBaseData::subtract(CCBaseData *from, CCBaseData *to)
|
|||
}
|
||||
}
|
||||
|
||||
void CCBaseData::setColor(ccColor4B &color)
|
||||
{
|
||||
r = color.r;
|
||||
g = color.g;
|
||||
b = color.b;
|
||||
a = color.a;
|
||||
}
|
||||
|
||||
ccColor4B CCBaseData::getColor()
|
||||
{
|
||||
return ccc4(r, g, b, a);
|
||||
}
|
||||
|
||||
|
||||
const char *CCDisplayData::changeDisplayToTexture(const char *displayName)
|
||||
{
|
||||
|
@ -242,13 +255,12 @@ CCArmatureData::~CCArmatureData()
|
|||
|
||||
bool CCArmatureData::init()
|
||||
{
|
||||
return boneList.init();
|
||||
return true;
|
||||
}
|
||||
|
||||
void CCArmatureData::addBoneData(CCBoneData *boneData)
|
||||
{
|
||||
boneDataDic.setObject(boneData, boneData->name);
|
||||
boneList.addObject(boneData);
|
||||
}
|
||||
|
||||
CCBoneData *CCArmatureData::getBoneData(const char *boneName)
|
||||
|
@ -385,6 +397,14 @@ bool CCContourData::init()
|
|||
{
|
||||
return vertexList.init();
|
||||
}
|
||||
void CCContourData::addVertex(CCPoint *vertex)
|
||||
{
|
||||
CCContourVertex2 *vertex2 = new CCContourVertex2(vertex->x, vertex->y);
|
||||
vertex2->autorelease();
|
||||
|
||||
vertexList.addObject(vertex2);
|
||||
}
|
||||
|
||||
|
||||
CCTextureData::CCTextureData()
|
||||
: height(0.0f)
|
||||
|
|
|
@ -81,6 +81,9 @@ public:
|
|||
* @param to to CCBaseData
|
||||
*/
|
||||
virtual void subtract(CCBaseData *_from, CCBaseData *_to);
|
||||
|
||||
virtual void setColor(ccColor4B &color);
|
||||
virtual ccColor4B getColor();
|
||||
public:
|
||||
float x; //! position x attribute
|
||||
float y; //! position y attribute
|
||||
|
@ -268,7 +271,6 @@ public:
|
|||
public:
|
||||
std::string name;
|
||||
CCDictionary boneDataDic;
|
||||
CCArray boneList;
|
||||
float dataVersion;
|
||||
};
|
||||
|
||||
|
@ -420,6 +422,7 @@ public:
|
|||
~CCContourData(void);
|
||||
|
||||
virtual bool init();
|
||||
virtual void addVertex(CCPoint *vertex);
|
||||
public:
|
||||
CCArray vertexList; //! Save contour vertex info, vertex saved in a CCPoint
|
||||
};
|
||||
|
|
|
@ -143,7 +143,7 @@ void CCDisplayFactory::createSpriteDisplay(CCBone *bone, CCDecorativeDisplay *de
|
|||
skin = CCSkin::createWithSpriteFrameName((textureName + ".png").c_str());
|
||||
}
|
||||
|
||||
CCTextureAtlas *atlas = CCSpriteFrameCacheHelper::sharedSpriteFrameCacheHelper()->getTextureAtlas((textureName + ".png").c_str());
|
||||
CCTextureAtlas *atlas = CCSpriteFrameCacheHelper::sharedSpriteFrameCacheHelper()->getTextureAtlasWithDisplayName((textureName + ".png").c_str());
|
||||
skin->setTextureAtlas(atlas);
|
||||
|
||||
CCTextureData *textureData = CCArmatureDataManager::sharedArmatureDataManager()->getTextureData(textureName.c_str());
|
||||
|
|
|
@ -57,6 +57,18 @@ CCSkin *CCSkin::createWithSpriteFrameName(const char *pszSpriteFrameName)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
CCSkin *CCSkin::create(const char *pszFileName)
|
||||
{
|
||||
CCSkin *skin = new CCSkin();
|
||||
if(skin && skin->initWithFile(pszFileName))
|
||||
{
|
||||
skin->autorelease();
|
||||
return skin;
|
||||
}
|
||||
CC_SAFE_DELETE(skin);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CCSkin::CCSkin()
|
||||
: m_pBone(NULL)
|
||||
{
|
||||
|
|
|
@ -35,6 +35,7 @@ class CCSkin : public CCSprite
|
|||
public:
|
||||
static CCSkin *create();
|
||||
static CCSkin *createWithSpriteFrameName(const char *pszSpriteFrameName);
|
||||
static CCSkin *create(const char *pszFileName);
|
||||
public:
|
||||
CCSkin();
|
||||
|
||||
|
|
|
@ -157,17 +157,22 @@ const char *CCSpriteFrameCacheHelper::getDisplayImagePath(const char *displayNam
|
|||
}
|
||||
|
||||
|
||||
CCTextureAtlas *CCSpriteFrameCacheHelper::getTextureAtlas(const char *displayName)
|
||||
CCTextureAtlas *CCSpriteFrameCacheHelper::getTextureAtlasWithImageName(const char *imageName)
|
||||
{
|
||||
const char *textureName = getDisplayImagePath(displayName);
|
||||
CCTextureAtlas *atlas = (CCTextureAtlas *)m_pDisplay2TextureAtlas->objectForKey(textureName);
|
||||
if (atlas == NULL)
|
||||
{
|
||||
atlas = CCTextureAtlas::createWithTexture(CCTextureCache::sharedTextureCache()->addImage(textureName), 4);
|
||||
m_pDisplay2TextureAtlas->setObject(atlas, textureName);
|
||||
}
|
||||
CCTextureAtlas *atlas = (CCTextureAtlas*)m_pDisplay2TextureAtlas->objectForKey(imageName);
|
||||
if (atlas == NULL)
|
||||
{
|
||||
atlas = CCTextureAtlas::createWithTexture(CCTextureCache::sharedTextureCache()->addImage(imageName), 4);
|
||||
m_pDisplay2TextureAtlas->setObject(atlas, imageName);
|
||||
}
|
||||
|
||||
return atlas;
|
||||
return atlas;
|
||||
}
|
||||
|
||||
CCTextureAtlas *CCSpriteFrameCacheHelper::getTextureAtlasWithDisplayName(const char *displayName)
|
||||
{
|
||||
const char *textureName = getDisplayImagePath(displayName);
|
||||
return getTextureAtlasWithImageName(textureName);
|
||||
}
|
||||
|
||||
CCSpriteFrameCacheHelper::CCSpriteFrameCacheHelper()
|
||||
|
|
|
@ -51,7 +51,9 @@ public:
|
|||
* Get this display in which image
|
||||
*/
|
||||
const char *getDisplayImagePath(const char *displayName);
|
||||
CCTextureAtlas *getTextureAtlas(const char *displayName);
|
||||
|
||||
cocos2d::CCTextureAtlas *getTextureAtlasWithImageName(const char *imageName);
|
||||
cocos2d::CCTextureAtlas *getTextureAtlasWithDisplayName(const char *displayName);
|
||||
|
||||
private:
|
||||
CCSpriteFrameCacheHelper();
|
||||
|
|
Loading…
Reference in New Issue