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


C# RectBox.GetWidth方法代码示例

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


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

示例1: IsCircToCirc

 /// <summary>
 /// 判断两个圆形是否发生了碰撞
 /// </summary>
 ///
 /// <param name="rect1"></param>
 /// <param name="rect2"></param>
 /// <returns></returns>
 public static bool IsCircToCirc(RectBox rect1, RectBox rect2)
 {
     Point middle1 = GetMiddlePoint(rect1);
     Point middle2 = GetMiddlePoint(rect2);
     float distance = middle1.DistanceTo(middle2);
     float radius1 = rect1.GetWidth() / 2;
     float radius2 = rect2.GetWidth() / 2;
     return (distance - radius2) < radius1;
 }
开发者ID:keppelcao,项目名称:LGame,代码行数:16,代码来源:CollisionHelper.cs

示例2: IsRectToCirc

 /// <summary>
 /// 检查矩形与圆形是否发生了碰撞
 /// </summary>
 ///
 /// <param name="rect1"></param>
 /// <param name="rect2"></param>
 /// <returns></returns>
 public static bool IsRectToCirc(RectBox rect1, RectBox rect2)
 {
     float radius = rect2.GetWidth() / 2;
     Point middle = GetMiddlePoint(rect2);
     Point upperLeft = new Point(rect1.GetMinX(), rect1.GetMinY());
     Point upperRight = new Point(rect1.GetMaxX(), rect1.GetMinY());
     Point downLeft = new Point(rect1.GetMinX(), rect1.GetMaxY());
     Point downRight = new Point(rect1.GetMaxX(), rect1.GetMaxY());
     bool collided = true;
     if (!IsPointToLine(upperLeft, upperRight, middle, radius))
     {
         if (!IsPointToLine(upperRight, downRight, middle, radius))
         {
             if (!IsPointToLine(upperLeft, downLeft, middle, radius))
             {
                 if (!IsPointToLine(downLeft, downRight, middle, radius))
                 {
                     collided = false;
                 }
             }
         }
     }
     return collided;
 }
开发者ID:keppelcao,项目名称:LGame,代码行数:31,代码来源:CollisionHelper.cs

示例3: Load

        private void Load(Stream ins0, string tileSetsLocation)
        {
            screenRect = LSystem.screenRect;

            tilesLocation = tileSetsLocation;

            try
            {
                XMLDocument doc = XMLParser.Parse(ins0);
                XMLElement docElement = doc.GetRoot();

                string orient = docElement.GetAttribute("orientation", "");
                if (!"orthogonal".Equals(orient))
                {
                    throw new Exception(
                            "Only orthogonal maps supported, found " + orient);
                }

                width = docElement.GetIntAttribute("width", 0);
                height = docElement.GetIntAttribute("height", 0);
                tileWidth = docElement.GetIntAttribute("tilewidth", 0);
                tileHeight = docElement.GetIntAttribute("tileheight", 0);

                XMLElement propsElement = (XMLElement)docElement
                        .GetChildrenByName("properties");
                if (propsElement != null)
                {
                    props = new TMXProperty();
                    List<XMLElement> property = propsElement.List("property");
                    for (int i = 0; i < property.Count; i++)
                    {
                        XMLElement propElement = property[i];
                        string name = propElement.GetAttribute("name", null);
                        string value_ren = propElement.GetAttribute("value", null);
                        props.SetProperty(name, value_ren);
                    }
                }

                if (loadTileSets)
                {
                    TMXTileSet tileSet = null;
                    TMXTileSet lastSet = null;

                    List<XMLElement> setNodes = docElement.List("tileset");
                    for (int i_0 = 0; i_0 < setNodes.Count; i_0++)
                    {
                        XMLElement current = setNodes[i_0];

                        tileSet = new TMXTileSet(this, current, true);
                        tileSet.index = i_0;

                        if (lastSet != null)
                        {
                            lastSet.SetLimit(tileSet.firstGID - 1);
                        }
                        lastSet = tileSet;

                        CollectionUtils.Add(tileSets, tileSet);
                    }
                }

                List<XMLElement> layerNodes = docElement.List("layer");
                for (int i_1 = 0; i_1 < layerNodes.Count; i_1++)
                {
                    XMLElement current_2 = layerNodes[i_1];
                    TMXLayer layer = new TMXLayer(this, current_2);
                    layer.index = i_1;

                    CollectionUtils.Add(layers, layer);
                }

                List<XMLElement> objectGroupNodes = docElement
                        .List("objectgroup");

                for (int i_3 = 0; i_3 < objectGroupNodes.Count; i_3++)
                {
                    XMLElement current_4 = objectGroupNodes[i_3];
                    TMXTileGroup objectGroup = new TMXTileGroup(current_4);
                    objectGroup.index = i_3;

                    CollectionUtils.Add(objectGroups, objectGroup);
                }

                defWidth = (int)(screenRect.GetWidth() / tileWidth);
                defHeight = (int)(screenRect.GetHeight() / tileHeight);

            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.StackTrace);
                throw new Exception("Failed to parse map", ex);
            }
        }
开发者ID:hellogithubtesting,项目名称:LGame,代码行数:93,代码来源:TMXTiledMap.cs

示例4: DrawChar

 protected internal void DrawChar(SpriteBatch batch, float x, float y, RectBox glyph,
         RectBox cropping, LColor color)
 {
     batch.Draw(texture, x + cropping.x, y + cropping.y, glyph.GetWidth(),
             glyph.GetHeight(), glyph.GetX(), glyph.GetY(),
             glyph.GetWidth(), glyph.GetHeight(), color);
 }
开发者ID:darragh-murphy,项目名称:LGame,代码行数:7,代码来源:SpriteFont.cs


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