本文整理汇总了C#中Microsoft.Xna.Framework.Graphics.Sprite.get_Texture方法的典型用法代码示例。如果您正苦于以下问题:C# Sprite.get_Texture方法的具体用法?C# Sprite.get_Texture怎么用?C# Sprite.get_Texture使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Xna.Framework.Graphics.Sprite
的用法示例。
在下文中一共展示了Sprite.get_Texture方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Check_Border_colision
/// <summary>
/// Determines if the obj passed is hitting the borders of the game world screen
/// and re-sets the position of the obj and its bounding box.
/// </summary>
/// <param name="graphics"></param>
/// <param name="obj"></param>
public static void Check_Border_colision(GraphicsDeviceManager graphics , Sprite obj)
{
float MaxX = graphics.GraphicsDevice.Viewport.Width - obj.get_Texture().Width * obj.get_Scale().X;
float MinX = 0;
float MaxY = graphics.GraphicsDevice.Viewport.Height - obj.get_Texture().Height * obj.get_Scale().Y;
float MinY = 0;
//Check for bounce
if (obj.Position.X > MaxX) // Right border check
{
obj.save_Position();
obj.Direction.X *= -1;
obj.Position.X = MaxX; // back up to meet colision surface
obj.set_box(); // allow boundingbox to follow sprite
if (obj.Type == "Ball") // Only produce sound if the obj is a Ball
Breakout.theSoundBank.PlayCue("BorderHit");
}
else if (obj.Position.X < MinX) // Left border check
{
obj.save_Position();
obj.Direction.X *= -1;
obj.Position.X = MinX;
obj.set_box();
if (obj.Type == "Ball") // Only produce sound if the obj is a Ball
Breakout.theSoundBank.PlayCue("BorderHit");
}
if (obj.Position.Y > MaxY) // Bottom border check
{
obj.save_Position();
obj.Direction.Y *= -1;
obj.Position.Y = MaxY;
obj.set_box();
if (obj.Type == "Ball") // Only produce sound if the obj is a Ball
Breakout.theSoundBank.PlayCue("BorderHit");
}
else if (obj.Position.Y < MinY) // Top border check
{
obj.save_Position();
obj.Direction.Y *= -1;
obj.Position.Y = MinY;
obj.set_box();
if (obj.Type == "Ball") // Only produce sound if the obj is a Ball
Breakout.theSoundBank.PlayCue("BorderHit");
}
}
示例2: Check_Sprite_colision
/// <summary>
/// Determines if the obj colide, re-sets obj and bounding box positions,
/// and checks what should be killed and what audio to play.
/// </summary>
/// <param name="obj1"></param>
/// <param name="obj2"></param>
/// <param name="isKillable"></param>
public static void Check_Sprite_colision(Sprite obj1, Sprite obj2, bool isKillable)
{
if (obj2.isActive)
{
if (obj1.box.Intersects(obj2.box))
{
if (obj1.Type == "Ball" || obj2.Type == "Ball")
ballCollided = true; // Flag for release of second ball in game version 2
if (obj1.Type == "Paddle" || obj2.Type == "Paddle") // Only produce sound if the obj is a Ball
Breakout.theSoundBank.PlayCue("PaddleHit");
if (isKillable)
{
Score_Manager.add_points(convertToBrick(obj2).get_Points());
brick_applyReflectPower((Ball)obj1, (Brick)obj2);
obj2.Kill();
Breakout.theSoundBank.PlayCue("BrickHit");
}
// Find Left/Right side
if (obj1.Prev_Pos_max.X < obj2.box.Min.X)
{
// Do left side computation
obj1.Direction.X *= -1;
obj1.Position.X = obj2.box.Min.X - obj1.get_Texture().Width;
obj1.box.Min.X = obj1.Position.X;
obj1.box.Max.X = obj2.box.Min.X;
}
else if (obj1.Prev_Pos_min.X > obj2.box.Max.X)
{
// Do right side computation
obj1.Direction.X *= -1;
obj1.Position.X = obj2.box.Max.X;
obj1.box.Min.X = obj1.Position.X;
obj1.box.Max.X = obj2.box.Max.X + obj2.get_Texture().Width;
}
// Find Top/Bottom side
if (obj1.Prev_Pos_max.Y < obj2.box.Min.Y)
{
// Do top side computation
obj1.Direction.Y *= -1;
obj1.Position.Y = obj2.box.Min.Y - obj1.get_Texture().Height;
obj1.box.Min.Y = obj1.Position.Y;
obj1.box.Max.Y = obj2.box.Min.Y;
}
else if (obj1.Prev_Pos_min.Y > obj2.box.Max.Y)
{
// Do bottom side computation
obj1.Direction.Y *= -1;
obj1.Position.Y = obj2.box.Max.Y;
obj1.box.Min.Y = obj1.Position.Y;
obj1.box.Max.Y = obj2.box.Max.Y + obj1.get_Texture().Height;
}
}
}
}