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


C++ CCSkeleton::getPosition方法代码示例

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


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

示例1: draw

void CCSpineDebugDrawNode::draw()
{
  CCObject* obj;
  
  CCARRAY_FOREACH(mSkeletons, obj)
  {
    CCSkeleton* skeletonNode = (CCSkeleton*) obj;
    const CCPoint skeletonPosition = skeletonNode->getPosition();
    
    // Slots
    if (getIsDrawingSlotBoundingBoxes())
    {
      const std::vector<Slot*>& slots = skeletonNode->skeleton->slots;
      ccV3F_C4B_T2F_Quad quad;
      
      // Green color for slot attachment bounding box
      ccDrawColor4B(0, 0, 255, 10);
      glLineWidth(1);
      
      for (int i = 0; i < slots.size(); i++)
      {
        if (slots[i]->attachment == NULL) continue;
        
        quad = ((RegionAttachment*) slots[i]->attachment)->quad;
        
        CCPoint points[4];
        points[0] = ccpAdd(ccp(quad.bl.vertices.x, quad.bl.vertices.y), skeletonPosition);
        points[1] = ccpAdd(ccp(quad.br.vertices.x, quad.bl.vertices.y), skeletonPosition);
        points[2] = ccpAdd(ccp(quad.tr.vertices.x, quad.tr.vertices.y), skeletonPosition);
        points[3] = ccpAdd(ccp(quad.tl.vertices.x, quad.tl.vertices.y), skeletonPosition);
        
        ccDrawPoly(points, 4, true);
      }
    }
    
    // Bones
    if (getIsDrawingBones())
    {
      const std::vector<Bone*>& bones = skeletonNode->skeleton->bones;
      Bone* bone = NULL;
      
      // Green color for bones
      glLineWidth(3);
      ccDrawColor4B(0, 255, 0, 255);
      
      // Bone line
      for (int i = 0; i < bones.size(); i++)
      {
        bone = bones[i];
        float x = bone->data->length * bone->m00 + bone->worldX;
        float y = bone->data->length * bone->m10 + bone->worldY;
        ccDrawLine(ccpAdd(ccp(bone->worldX, bone->worldY), skeletonPosition),
                   ccpAdd(ccp(x, y), skeletonPosition));
      }
      
      // Bone head
      ccPointSize(5);
      // Root bone head is assigned blue color
      ccDrawColor4B(0, 0, 255, 255);
      for (int i = 0; i < bones.size(); i++)
      {
        bone = bones[i];
        ccDrawPoint(ccpAdd(ccp(bone->worldX, bone->worldY), skeletonPosition));
        
        // Restore green color for other bone heads
        if (i == 0)
          ccDrawColor4B(0, 255, 0, 255);
      }
    }
  }
开发者ID:nhanv,项目名称:spine-cocos2dx-debugdraw,代码行数:70,代码来源:CCSpineDebugDrawNode.cpp


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