ADD SKELETON NEST TEST CASE

This commit is contained in:
geron-cn 2015-07-29 10:23:03 +08:00
parent fa5d70fc04
commit 7e05538521
1 changed files with 33 additions and 0 deletions

View File

@ -514,6 +514,39 @@ void TestActionTimelineSkeleton::onEnter()
leftleg->setVisible(!leftleg->isVisible());
// bug fixed while leftleg's child hide with leftleg's visible
});
/************* Skeleton nest Skeleton test *************/
auto nestSkeletonBtn = cocos2d::ui::Button::create();
nestSkeletonBtn->setTitleText("Skeleton Nest");
nestSkeletonBtn->setPosition(Vec2(VisibleRect::right().x - 40, VisibleRect::top().y - 120));
addChild(nestSkeletonBtn);
auto nestSkeleton = static_cast<SkeletonNode*>(CSLoader::createNode("ActionTimeline/DemoPlayer_skeleton.csb"));
nestSkeleton->retain();
ActionTimeline* nestSkeletonAction = action->clone();
nestSkeletonAction->retain();
nestSkeleton->runAction(nestSkeletonAction);
nestSkeleton->setScale(0.2f);
nestSkeleton->setPosition(150, 300);
nestSkeletonAction->gotoFrameAndPlay(0);
// show debug draws, or comment this for hide bones draws
for (auto& nestbonechild : nestSkeleton->getAllSubBonesMap())
{
nestbonechild.second->setDebugDrawEnabled(true);
}
nestSkeletonBtn->addClickEventListener([leftleg, nestSkeleton, nestSkeletonAction](Ref* sender)
{
if (nestSkeleton->getParent() == nullptr)
{
leftleg->addChild(nestSkeleton);
}
else
{
nestSkeleton->removeFromParentAndCleanup(false);
}
// bug fixed while leftleg's child hide with leftleg's visible
});
}
std::string TestActionTimelineSkeleton::title() const