そのため、レンダー ターゲットからの結果を色の配列に格納して、反復子で個別に操作できるようにしようとしています。何らかの理由で、以下のコードは配列内のすべての値を R=0、G=0、B=0、A=0 に設定します。まるで初期化されていないかのように。GetData メソッドの使い方が間違っていませんか? それは何か他のものですか?それは非常にカラフルな画像でなければならず、絶対に透明ではありません.
問題は、テクスチャが正しく描画されていないことではなく、レンダー ターゲットを設定せずに (デフォルトのバックバッファを使用して) コードを実行したところ、ゲームは完全に正常に実行されました。
//Creating a new render target and setting it
RenderTarget2D unprocessed = new RenderTarget2D(graphics.GraphicsDevice, Window.ClientBounds.Width, Window.ClientBounds.Height,false,SurfaceFormat.Color,DepthFormat.Depth24,4,RenderTargetUsage.PreserveContents);
graphics.GraphicsDevice.SetRenderTarget(unprocessed);
//Drawing background and main player
spriteBatch.Draw(bgTex,new Rectangle(0,0,Window.ClientBounds.Width,Window.ClientBounds.Height),Color.White);
mainPlayer.Draw(spriteBatch);
//resetting render target
graphics.GraphicsDevice.SetRenderTarget(null);
//creating array of Color to copy render to
Color[] baseImage = new Color[Window.ClientBounds.Width * Window.ClientBounds.Height];
//I pause the program here and baseImage is an array of black transparent colors
unprocessed.GetData<Color>(baseImage);
spriteBatch.End();