本文整理汇总了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;
}