private void occupiedcheck(Vector2 positionv, Texture2D positiont)
{
int xpos=(((int)positionv.X+100)/150);
int ypos=(((int)positionv.Y+110)/150);
for (int j = 0; j < 4; j++)
{
if (piecexarray[j] == xpos && pieceyarray[j] == ypos)
{
}
else
{
positiont = Content.Load<Texture2D>("Graphics/Highlighter");
break;
}
}
}上面你可以看到我为C#游戏写的一个函数,当函数的‘Texture2D’部分被激活时,我希望它将传入的纹理(Texture2D位置)更改为“图形/高亮显示”。目前它不起作用,我如何获得它,以便我可以将现有的Texture2D传递到函数中,并通过函数中的“Content.Load”方法动态更改它。
发布于 2013-01-26 12:59:15
您可以在您的方法中使用ref方法参数关键字,以便"[a]ny changes made to the parameter in the method will be reflected in that variable when control passes back to the calling method":
private void occupiedcheck(Vector2 positionv, ref Texture2D positiont)
{
// ...
}https://stackoverflow.com/questions/14533406
复制相似问题