どこを間違えたのかわかりません。YouTubeで、約100万個の粒子をリアルタイムでレンダリングするデモを見たことがあります(驚くべきことです)。しかし、2500の小さなスクエア(Texture2D)だけをレンダリングしたい場合、システムはひざまずきます-すべてが遅くてぎくしゃくしています。ここでは、ループをそのまま表示します。単純なタイルからタイルへのレンダリングです。グリッドは50x50で、Texture2Dタイルは5x5の大きなpng画像とGridNode3x3のみです。私はXNAの初心者なので、あまり殴らないでください... :-)
誰か教えてもらえますか、私は何を間違えますか?
どうもありがとう
for (x = FromCol; x <= ToCol; x++)
{
for (y = FromRow; y <= ToRow; y++)
{
Color aColor = new Color((byte)(x * 20), (byte)(y * 15), (byte)(60 + x));
CoordX = DisplayArea.Left + (int)Math.Round((x - FromCol) * zoomWidth - (restCol * ZoomingX) - indent_x);//
CoordY = DisplayArea.Top + (int)Math.Round((y - FromRow) * zoomHeight - (restRow * ZoomingY) - indent_y);//
dodraw = ((CoordX) > DisplayArea.Left) & (CoordX < (DisplayArea.Right - indent_x)) & ((CoordY) > DisplayArea.Top) & (CoordY < (DisplayArea.Bottom-indent_y));
l = CoordX + indent_x;
t = CoordY + indent_y;
r = l + (int)Math.Round(ColWidth * ZoomingX);
b = t + (int)Math.Round(RowHeight * ZoomingY);
if (l < DisplayArea.Left) l = DisplayArea.Left;
if (t < DisplayArea.Top) t = DisplayArea.Top;
if (r > (DisplayArea.Left + DisplayArea.Width)) r = DisplayArea.Left + DisplayArea.Width;
if (b > DisplayArea.Top + DisplayArea.Height) b = DisplayArea.Top + DisplayArea.Height;
SpriteBatch.Draw(Tile, new Rectangle(l, t, r - l, b - t), aColor);
if (dodraw) SpriteBatch.Draw(GridNode, new Vector2(CoordX, CoordY), Color.White);
}