当前位置: 首页>>代码示例>>C++>>正文


C++ ActionTimeline::retain方法代码示例

本文整理汇总了C++中ActionTimeline::retain方法的典型用法代码示例。如果您正苦于以下问题:C++ ActionTimeline::retain方法的具体用法?C++ ActionTimeline::retain怎么用?C++ ActionTimeline::retain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActionTimeline的用法示例。


在下文中一共展示了ActionTimeline::retain方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onEnter


//.........这里部分代码省略.........
    }, 0, "update debug draw");


    // change displays , can be use for dress up a skeleton
    auto changeBoneDispsBtn = cocos2d::ui::Button::create();
    addChild(changeBoneDispsBtn);
    changeBoneDispsBtn->setPosition(Vec2(VisibleRect::right().x - 60, VisibleRect::top().y - 75));
    changeBoneDispsBtn->setTitleText("change bone displays");

    std::map < std::string, std::string> boneSkinNames;
    boneSkinNames.insert(std::make_pair("Layer20", "fire"));
    boneSkinNames.insert(std::make_pair("Layer14", "fruit"));
    skeletonNode->addSkinGroup("fruitKnife", boneSkinNames);

    std::map < std::string, std::string> boneSkinNames2;
    boneSkinNames2.insert(std::make_pair("Layer20", "3"));
    boneSkinNames2.insert(std::make_pair("Layer14", "hat"));
    skeletonNode->addSkinGroup("cowboy", boneSkinNames2);

    changeBoneDispsBtn->addClickEventListener([skeletonNode, this](Ref* sender)
    {
        if (!_changedDisplays)
        {
            skeletonNode->changeSkins("fruitKnife");
            _changedDisplays = true;
        }
        else
        {
            skeletonNode->changeSkins("cowboy");
            _changedDisplays = false;
        }
    });


    /*********** test cases for bugs        **********/
    // bug: #13060 https://github.com/cocos2d/cocos2d-x/issues/13060
    // bug: bone draw at the other edge when move to outside right edge.
    BoneNode* bugtestBoneNode = BoneNode::create(500);
    bugtestBoneNode->setRotation(-10);
    bugtestBoneNode->retain();
    bugtestBoneNode->setDebugDrawEnabled(true);
    bugtestBoneNode->setPosition(Vec2(1500, VisibleRect::top().y - 90));
    auto bug13060Btn = cocos2d::ui::Button::create();
    bug13060Btn->setPosition(Vec2(VisibleRect::right().x - 30, VisibleRect::top().y - 90));
    bug13060Btn->setTitleText("bug #13060");
    addChild(bug13060Btn);
    bug13060Btn->addClickEventListener([bugtestBoneNode, skeletonNode](Ref* sender)
    {
        if (bugtestBoneNode->getParent() == nullptr)
            skeletonNode->addChild(bugtestBoneNode);
        else
            bugtestBoneNode->removeFromParent();
        // bug fixed while bugtestBoneNode not be drawn at the bottom edge
    });

    // bug: #13005 https://github.com/cocos2d/cocos2d-x/issues/#13005
    // bug: BoneNode 's debugdraw can not be controlled by ancestor's visible
    auto leftleg = skeletonNode->getBoneNode("Layer26");
    auto bug13005Btn = cocos2d::ui::Button::create();
    addChild(bug13005Btn);
    bug13005Btn->setPosition(Vec2(VisibleRect::right().x - 30, VisibleRect::top().y - 105));
    bug13005Btn->setTitleText("bug #13005");
    bug13005Btn->addClickEventListener([leftleg](Ref* sender)
    {
        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);
        }
    });
}
开发者ID:,项目名称:,代码行数:101,代码来源:


注:本文中的ActionTimeline::retain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。