本文整理汇总了C++中Bone::changeDisplayWithIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Bone::changeDisplayWithIndex方法的具体用法?C++ Bone::changeDisplayWithIndex怎么用?C++ Bone::changeDisplayWithIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bone
的用法示例。
在下文中一共展示了Bone::changeDisplayWithIndex方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onEnter
void TestParticleDisplay::onEnter()
{
ArmatureTestLayer::onEnter();
auto listener = EventListenerTouchAllAtOnce::create();
listener->onTouchesEnded = CC_CALLBACK_2(TestParticleDisplay::onTouchesEnded, this);
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
animationID = 0;
armature = Armature::create("robot");
armature->getAnimation()->playWithIndex(0);
armature->setPosition(VisibleRect::center());
armature->setScale(0.48f);
armature->getAnimation()->setSpeedScale(0.5f);
addChild(armature);
ParticleSystem *p1 = CCParticleSystemQuad::create("Particles/SmallSun.plist");
ParticleSystem *p2 = CCParticleSystemQuad::create("Particles/SmallSun.plist");
Bone *bone = Bone::create("p1");
bone->addDisplay(p1, 0);
bone->changeDisplayWithIndex(0, true);
bone->setIgnoreMovementBoneData(true);
bone->setLocalZOrder(100);
bone->setScale(1.2f);
armature->addBone(bone, "bady-a3");
bone = Bone::create("p2");
bone->addDisplay(p2, 0);
bone->changeDisplayWithIndex(0, true);
bone->setIgnoreMovementBoneData(true);
bone->setLocalZOrder(100);
bone->setScale(1.2f);
armature->addBone(bone, "bady-a30");
}
示例2: changeMount
void Hero::changeMount(Armature *armature)
{
if (armature == nullptr)
{
retain();
playWithIndex(0);
//Remove hero from display list
m_pMount->getBone("hero")->removeDisplay(0);
m_pMount->stopAllActions();
//Set position to current position
setPosition(m_pMount->getPosition());
//Add to layer
m_pLayer->addChild(this);
release();
setMount(armature);
}
else
{
setMount(armature);
retain();
//Remove from layer
removeFromParentAndCleanup(false);
//Get the hero bone
Bone *bone = armature->getBone("hero");
//Add hero as a display to this bone
bone->addDisplay(this, 0);
//Change this bone's display
bone->changeDisplayWithIndex(0, true);
bone->setIgnoreMovementBoneData(true);
setPosition(Vec2(0,0));
//Change animation
playWithIndex(1);
setScale(1);
release();
}
}
示例3: init
bool Armature::init(const std::string& name)
{
bool bRet = false;
do
{
removeAllChildren();
CC_SAFE_DELETE(_animation);
_animation = new ArmatureAnimation();
_animation->init(this);
_boneDic.clear();
_topBoneList.clear();
_blendFunc = BlendFunc::ALPHA_NON_PREMULTIPLIED;
_name = name;
ArmatureDataManager *armatureDataManager = ArmatureDataManager::getInstance();
if(!_name.empty())
{
AnimationData *animationData = armatureDataManager->getAnimationData(name);
CCASSERT(animationData, "AnimationData not exist! ");
_animation->setAnimationData(animationData);
ArmatureData *armatureData = armatureDataManager->getArmatureData(name);
CCASSERT(armatureData, "");
_armatureData = armatureData;
for (auto& element : armatureData->boneDataDic)
{
Bone *bone = createBone(element.first.c_str());
//! init bone's Tween to 1st movement's 1st frame
do
{
MovementData *movData = animationData->getMovement(animationData->movementNames.at(0).c_str());
CC_BREAK_IF(!movData);
MovementBoneData *movBoneData = movData->getMovementBoneData(bone->getName().c_str());
CC_BREAK_IF(!movBoneData || movBoneData->frameList.size() <= 0);
FrameData *frameData = movBoneData->getFrameData(0);
CC_BREAK_IF(!frameData);
bone->getTweenData()->copy(frameData);
bone->changeDisplayWithIndex(frameData->displayIndex, false);
}
while (0);
}
update(0);
updateOffsetPoint();
}
else
{
_name = "new_armature";
_armatureData = ArmatureData::create();
_armatureData->name = _name;
AnimationData *animationData = AnimationData::create();
animationData->name = _name;
armatureDataManager->addArmatureData(_name.c_str(), _armatureData);
armatureDataManager->addAnimationData(_name.c_str(), animationData);
_animation->setAnimationData(animationData);
}
setGLProgramState(GLProgramState::getOrCreateWithGLProgramName(GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR));
setCascadeOpacityEnabled(true);
setCascadeColorEnabled(true);
bRet = true;
}
while (0);
return bRet;
}