[英]Updating each Item in a list
So, I've created a list with 2 objects in. I want to make sure they both update.所以,我创建了一个包含 2 个对象的列表。我想确保它们都更新。
public static void Update(GameTime gameTime)
{
Player.Update(gameTime);
Seagull.Update(gameTime);
foreach (Seagull seagull in seagulls)
{
seagull.Update(gameTime);//Here is where the error is.
}
}
This is the error observed Error这是观察到的错误 Error
Help would be greatly appreciated.帮助将不胜感激。
the error tells us that seagull.Update
is a static method, which means it can't be called for each seagull, only for 'seagulls' as a whole.该错误告诉我们seagull.Update
是一个静态方法,这意味着不能为每个海鸥调用它,只能为整个 'seagulls' 调用。 I suspect you don't want this, and will need to stop it being a static method (by removing the static
keyword).我怀疑你不想要这个,并且需要阻止它成为静态方法(通过删除static
关键字)。
For more information on static methods: What's a "static method" in C#?有关静态方法的更多信息: 什么是 C# 中的“静态方法”? https://msdn.microsoft.com/en-gb/library/98f28cdx.aspx https://msdn.microsoft.com/en-gb/library/98f28cdx.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.