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


C# Layer.SetMainLayer方法代码示例

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


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

示例1: GenerateSection

        /// <summary>
        ///   Creates a test section.
        /// </summary>
        /// <param name="owner">The level that will own this section.</param>
        /// <returns>
        ///   A section consisting of randomly placed and sized rows of concrete
        ///   blocks with a TestPlayer.
        /// </returns>
        public static Section GenerateSection(Level owner)
        {
            // Create a section of randomly placed stretches of stone tiles.

            Section result = new Section(owner);

            result.Bounds = new Physics.BoundingRectangle(0, 0, 3200, 1920);
            result.AutoscrollSettings = new Physics.SectionAutoscrollSettings(CameraScrollType.FreelyMoving, Vector2.Zero, null);
            result.Background = GenerateBackground(result);

            Layer mainLayer = new Layer(result, false);
            result.Layers.Add(mainLayer);
            mainLayer.SetMainLayer();

            Random random = new Random();
            float tilePlacerX = 0f;
            float tilePlacerY = 200f;

            // really temporary
            // AssemblyManager.LoadAssembly(System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
            // "TestPackage", "SmlSample.dll")); hey it actually was temporary
            // TODO: have ContentPackageManager ignore multiple attempts to add
            //       the same package

            Tile testTile3 = AssemblyManager.GetTileByFullName("SmlSample.TestTile3");
            testTile3.GraphicsResourceName = "smw_concrete_block";

            while (tilePlacerX < 1008f)
            {
                int runDistance = random.Next(3, 8);
                tilePlacerY += (random.Next(1, 3) * 16f) * ((random.Next(0, 2) != 0) ? 1 : -1);
                tilePlacerY -= (tilePlacerY % 16);
                tilePlacerY = MathHelper.Clamp(tilePlacerY, 0, 1920);

                for (int i = 0; i < runDistance; i++)
                {
                    Tile newTile = testTile3.Clone();
                    newTile.Position = new Vector2(tilePlacerX, tilePlacerY);
                    result.AddTile(newTile);
                    tilePlacerX += 16f;
                }
            }

            Sprite player = AssemblyManager.GetSpriteByFullName("SmlSample.SimplePlayer");
            player.Position = Vector2.Zero;
            player.IsActive = true;
            player.State = (SpriteState)0;
            player.TileCollisionMode = SpriteCollisionMode.OffsetNotify;
            result.AddSprite(player);

            Sprite painter = AssemblyManager.GetSpriteByFullName("SmlSample.PainterSprite");
            painter.Position = new Vector2(16f, 0f);
            painter.IsActive = true;
            painter.State = (SpriteState)0;
            painter.TileCollisionMode = SpriteCollisionMode.NoCollision;
            result.AddSprite(painter);

            return result;
        }
开发者ID:smldev,项目名称:smlimitless,代码行数:67,代码来源:TestSectionGenerator.cs


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