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


C++ Point2d::SetValues方法代码示例

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


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

示例1: type

Member::Member(const xmlNode *     xml,
               const std::string & main_folder)
  : parent(NULL)
  , angle_rad(0)
  , alpha(0)
  , go_through_ground(false)
  , pos(0,0)
  , scale(0,0)
  , spr(NULL)
  , name("")
  , type("")
  , anchor(0,0)
{
  XmlReader::ReadStringAttr(xml, "name", name);
  ASSERT(name!="");

  // Load the sprite
  spr = GetResourceManager().LoadSprite(xml, name, main_folder);
  spr->EnableCaches(true, 0);

  // Get the various option
  std::string type_str;
  XmlReader::ReadStringAttr(xml, "type", type_str);
  ASSERT(type_str!="");
  type = MemberType(type_str);

  const xmlNode * el = XmlReader::GetMarker(xml, "anchor");

  if (el) {
    int dx = 0, dy = 0;
    XmlReader::ReadIntAttr(el, "dx", dx);
    XmlReader::ReadIntAttr(el, "dy", dy);
    MSG_DEBUG("body", "   Member %s has anchor (%i,%i)\n", name.c_str(), dx, dy);
    anchor = Point2d(dx, dy);
    spr->SetRotation_HotSpot(Point2i(dx, dy));
  } else {
    MSG_DEBUG("body", "   Member %s has no anchor\n", name.c_str());
  }

  XmlReader::ReadBoolAttr(xml, "go_through_ground", go_through_ground);

  xmlNodeArray                 nodes = XmlReader::GetNamedChildren(xml, "attached");
  xmlNodeArray::const_iterator it    = nodes.begin();
  xmlNodeArray::const_iterator itEnd = nodes.end();

  std::string att_type;
  int         dx = 0;
  int         dy = 0;
  Point2d     d;     // TODO: Rename !!
  std::string frame_str;

  for (; it != itEnd; ++it) {
    //std::string att_type; // TODO lami : can be move ?!

    if (!XmlReader::ReadStringAttr(*it, "member_type", att_type)) {
      std::cerr << "Malformed attached member definition" << std::endl;
      continue;
    }
    MemberType type(att_type);

    XmlReader::ReadIntAttr(*it, "dx", dx);
    XmlReader::ReadIntAttr(*it, "dy", dy);
    MSG_DEBUG("body", "   Attached member %s has anchor (%i,%i)\n", att_type.c_str(), dx, dy);
    d.SetValues(dx, dy);
    XmlReader::ReadStringAttr(*it, "frame", frame_str);

    if ("*" == frame_str) {
      v_attached rot_spot;
      rot_spot.assign(spr->GetFrameCount(), d);
      attached_types[type] = rot_spot;
    } else {
      int frame;

      if (!str2int(frame_str, frame) || frame < 0 || frame >= (int)spr->GetFrameCount()) {
        std::cerr << "Malformed attached member definition (wrong frame number)" << std::endl;
        continue;
      }

      if (attached_types.find(type) == attached_types.end()) {
        v_attached rot_spot;
        rot_spot.resize(spr->GetFrameCount(), Point2d(0.0, 0.0));
        attached_types[type] = rot_spot;
      }
      (attached_types.find(type)->second)[frame] = d;
    }
  }

  AttachTypeMap::iterator attachment_it = attached_types.begin();
  for (; attachment_it != attached_types.end(); ++attachment_it)
    attachment_it->second.SetAnchor(anchor);

  ResetMovement();
}
开发者ID:yeKcim,项目名称:warmux,代码行数:93,代码来源:member.cpp


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