本文整理汇总了C#中Microsoft.Xna.Framework.Rectangle.Select方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Select方法的具体用法?C# Rectangle.Select怎么用?C# Rectangle.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Rectangle
的用法示例。
在下文中一共展示了Rectangle.Select方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAnimation
/// <summary>
/// Extracts a <see cref="Jv.Games.Xna.Sprites.Animation"/> with the specified frame locations.
/// </summary>
/// <param name="name">Name of the extracted animation.</param>
/// <param name="frameRects">Location coordinates of each frame in the animation.</param>
/// <param name="frameDuration">How long each frame is displayed, before switching to the next frame.</param>
/// <param name="repeat"><c>True</c> if the animation should repeat after the last frame finishes.</param>
/// <returns>The extracted animation.</returns>
public Animation GetAnimation(string name, Rectangle[] frameRects, TimeSpan frameDuration, bool repeat = true)
{
if (frameRects.Length <= 0 ||
frameRects.Any(r => r.Width <= 0 || r.Height <= 0) ||
frameRects.Any(r => r.X + r.Width > Texture.Width || r.Y + r.Height > Texture.Height))
throw new ArgumentOutOfRangeException("frameRects");
if (frameDuration <= TimeSpan.Zero)
throw new ArgumentOutOfRangeException("frameDuration");
var frames = frameRects.Select(r => new Frame(Texture, r)).ToArray();
var duration = TimeSpan.FromSeconds(frameDuration.TotalSeconds * frames.Length);
if (repeat)
return new LoopedAnimation(name, frames, duration, 0, null);
return new Animation(name, frames, duration);
}