【发布时间】:2013-11-26 10:15:27
【问题描述】:
我正在使用 XNA 3.0 并尝试制作一个精灵类,但不确定如何处理它。我是否在精灵类中执行动画?我的代码也不断收到错误
Game1.cs
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
spriteBatch.Begin();
Sprite.Draw(spriteBatch);
base.Draw(gameTime);
}
Sprite.cs
private static Texture2D rings;
Point rings_frameSize = new Point(75, 75);
Point rings_currentFrame = new Point(0, 0);
Point rings_sheetSize = new Point(6, 8);
int ms_elapsedRings = 0;
public static void setup_sprites(ContentManager Content)
{
rings = Content.Load<Texture2D>("Images/threerings");
}
public void Draw(SpriteBatch spriteBatch)
{
spriteBatch.Draw(rings,
new Vector2(0,0),
new Rectangle(rings_currentFrame.X * rings_frameSize.X, //X component of where to begin
rings_currentFrame.Y * rings_frameSize.Y, //Y component of where to begin
rings_frameSize.X, //cell width
rings_frameSize.Y), //cell height
Color.White,
0,
Vector2.Zero,
1,
SpriteEffects.None,
0);
}
返回
错误 1 非静态字段、方法或属性 'WindowsGame1.Sprite.Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch)' C:\Users\XXXXXX\Documents\Visual Studio 需要对象引用2008\Projects\WindowsGame1\WindowsGame1\Game1.cs 107 13 WindowsGame1
【问题讨论】:
标签: c# animation xna sprite xna-3.0