0
我有一个云和一个人精灵,这些都是分开绘制,但由于某些原因,他们一起绘制并重叠,然后将自己定位在两个精灵的定义位置。图像重叠和绘制两次
我的精灵类:
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);
}
这岂不意味着每一个形象我就必须有'雪碧云=新的雪碧(){位置=新Vector2(100,100),纹理= Content.Load( “CloudTexture”)} ' –
或者我想加载的每个精灵都有类似的问题 –
还有加载内容的问题。 –