fix add display

This commit is contained in:
2youyou2 2013-09-23 16:48:09 +08:00
parent e1acbb6af4
commit 90d7abb3ca
5 changed files with 95 additions and 83 deletions

View File

@ -261,17 +261,11 @@ void Armature::addBone(Bone *bone, const char *parentName)
}
else
{
if (_parentBone)
_parentBone->addChildBone(bone);
else
_topBoneList->addObject(bone);
}
}
else
{
if (_parentBone)
_parentBone->addChildBone(bone);
else
_topBoneList->addObject(bone);
}
@ -338,7 +332,7 @@ Dictionary *Armature::getBoneDic()
return _boneDic;
}
const AffineTransform& Armature::getNodeToParentTransform() const
const AffineTransform &Armature::getNodeToParentTransform() const
{
if (_transformDirty)
{
@ -452,7 +446,7 @@ void Armature::update(float dt)
Object *object = NULL;
CCARRAY_FOREACH(_topBoneList, object)
{
static_cast<Bone*>(object)->update(dt);
static_cast<Bone *>(object)->update(dt);
}
_armatureTransformDirty = false;
@ -523,6 +517,8 @@ void Armature::draw()
}
}
armature->draw();
_atlas = armature->getTextureAtlas();
}
break;
default:
@ -679,7 +675,7 @@ Bone *Armature::getBoneAtPoint(float x, float y)
for(int i = length - 1; i >= 0; i--)
{
bs = static_cast<Bone*>( _children->getObjectAtIndex(i) );
bs = static_cast<Bone *>( _children->getObjectAtIndex(i) );
if(bs->getDisplayManager()->containPoint(x, y))
{
return bs;

View File

@ -165,6 +165,13 @@ void Bone::update(float delta)
if (_parentBone)
_boneTransformDirty = _boneTransformDirty || _parentBone->isTransformDirty();
CCBone *armatureParentBone = _armature->getParentBone();
if (armatureParentBone && !_boneTransformDirty)
{
_boneTransformDirty = armatureParentBone->isTransformDirty();
}
if (_boneTransformDirty)
{
if (_armature->getArmatureData()->dataVersion >= VERSION_COMBINED)
@ -182,6 +189,13 @@ void Bone::update(float delta)
{
_worldTransform = AffineTransformConcat(_worldTransform, _parentBone->_worldTransform);
}
else
{
if (armatureParentBone)
{
_worldTransform = CCAffineTransformConcat(_worldTransform, armatureParentBone->getNodeToArmatureTransform());
}
}
}
DisplayFactory::updateDisplay(this, _displayManager->getCurrentDecorativeDisplay(), delta, _boneTransformDirty || _armature->getArmatureTransformDirty());
@ -211,7 +225,7 @@ void Bone::updateDisplayedOpacity(GLubyte parentOpacity)
updateColor();
}
void Bone::setColor(const Color3B& color)
void Bone::setColor(const Color3B &color)
{
CCNodeRGBA::setColor(color);
updateColor();

View File

@ -135,6 +135,7 @@ void DisplayManager::addDisplay(Node *display, int index)
if (SpriteDisplayData *spriteDisplayData = (SpriteDisplayData *)decoDisplay->getDisplayData())
{
skin->setSkinData(spriteDisplayData->skinData);
((CCSpriteDisplayData *)displayData)->skinData = spriteDisplayData->skinData;
}
else
{

View File

@ -118,6 +118,7 @@ void Skin::setSkinData(const BaseData &var)
setPosition(Point(_skinData.x, _skinData.y));
_skinTransform = getNodeToParentTransform();
updateArmatureTransform();
}
const BaseData &Skin::getSkinData() const

View File

@ -136,7 +136,7 @@ static const char *CONFIG_FILE_PATH = "config_file_path";
NS_CC_EXT_ARMATURE_BEGIN
std::vector<std::string> s_arrConfigFileList;
std::vector<std::string> s_arrConfigFileList;
float s_PositionReadScale = 1;
static float s_FlashToolVersion = VERSION_2_0;
static float s_CocoStudioVersion = VERSION_COMBINED;