我有一个云和一个人精灵,它们都是分开绘制的,但由于某种原因,它们被绘制在一起并重叠,然后将自己定位在两个精灵的定义位置。
我的精灵类:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
namespace MarioFake
{
class Sprites
{
public Vector2 MarioPosition = new Vector2(200, 200);
private Texture2D MarioStill;
public Vector2 LargeCloudPosition = new Vector2(100, 100);
private Texture2D LargeCloud;
public void LoadContent(ContentManager theContentManager, string theAssetName)
{
MarioStill = theContentManager.Load<Texture2D>(theAssetName);
LargeCloud = theContentManager.Load<Texture2D>(theAssetName);
}
public void Draw(SpriteBatch theSpriteBatch)
{
theSpriteBatch.Draw(MarioStill, MarioPosition, Color.White);
theSpriteBatch.Draw(LargeCloud, LargeCloudPosition, Color.White);
}
}
}
以及我的游戏类中的绘图方法:
protected override void Draw(GameTime gameTime)
{
graphics.GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
MarioStill.Draw(this.spriteBatch);
LargeCloud.Draw(this.spriteBatch);
spriteBatch.End();
base.Draw(gameTime);
}