XNA 框架:ContentManager.Content.Load(“10by10tile”) 是一种“方法”;但用作“类型”;
如果这太愚蠢了,我很抱歉,但对于 C#,尤其是 XNA 框架,我完全是新手。我收到上面的错误消息;到底为什么它适用于 Platformer1 的玩家代码但不适用于我?!
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;
using Microsoft.Xna.Framework.Input;
namespace WindowsGame1
{
class Cell
{
public bool alive;
public Texture2D CSprite;
public int x
{
get { return x; }
set { x = value; }
}
public int y
{
get { return y; }
set { y = value; }
}
public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
{
}
public void Update(GameTime gameTime)
{
}
protected override void LoadContent()
{
//spriteBatch = new SpriteBatch(GraphicsDevice);
CSprite = new ContentManager.Load<Texture2D>("10by10tile"); // TODO: This does NOT work for some reason.
}
}
}
I'm sorry if this is insanely stupid, but I'm a total newbie when it comes to C# and especially the XNA Framework. I got the error message from above; why in the heck does it work for Platformer1's Player code but not for me?!
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;
using Microsoft.Xna.Framework.Input;
namespace WindowsGame1
{
class Cell
{
public bool alive;
public Texture2D CSprite;
public int x
{
get { return x; }
set { x = value; }
}
public int y
{
get { return y; }
set { y = value; }
}
public void Draw(GameTime gameTime, SpriteBatch spriteBatch)
{
}
public void Update(GameTime gameTime)
{
}
protected override void LoadContent()
{
//spriteBatch = new SpriteBatch(GraphicsDevice);
CSprite = new ContentManager.Load<Texture2D>("10by10tile"); // TODO: This does NOT work for some reason.
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您可能希望将 contentmanager 的实例(来自您的 Game 类的 this.Content)传递给您的加载内容函数。
编辑:不是为了欺骗你或任何东西 - 但这是一个简单但有用的教程,可以推动你走向正确的方向XNA 的指导,它应该能够向您展示您需要的所有基础知识。
I'm thinking that you may want to pass the instance of contentmanager - (this.Content from your Game class) - to your load content function.
Edit: Not to palm you off or anything - but this is a simple - but useful tutorial to push you in the right direction with XNA, which should be able to show you all the basics you need.
ContentManager.Load 是一种方法。您不需要“新”声明。尝试:
ContentManager.Load is a method. You don't need the "new" statement. Try: