| Poster | : Blackelfwolf | | Posts | : 3 | | Country | : new zealand | | City | : christchurch |
| | | | Posted by Blackelfwolf on 13/05/2012 at 23:13:41
| | Hello, I have followed your tutorial exactly.
but have been getting 3 errors since this part of the tutorial.
These are the errors:
1. Cannot implicitly convert type 'int[]' to 'int'
2. Cannot apply indexing with [] to an expression of type 'int'
3. Cannot apply indexing with [] to an expression of type 'int'
private void GenerateTerrainContour()
{
terrainContour = new int[screenWidth]; // ^ first ^ error ^
for (int x = 0; x < screenWidth; x++)
{
terrainContour[x] = screenHeight / 2;
// ^ Second ^ error ^
}
}
private void CreateForeground()
{
Color[] foregroundColors = new Color[screenWidth * screenHeight];
for (int x = 0; x < screenWidth; x++)
{
for (int y = 0; y < screenHeight; y++)
{
if (y > terrainContour[x])
{ // 3rd ^ ^ error ^
foregroundColors[x + y * screenWidth] = Color.Green;
}
else
{
foregroundColors[x + y * screenWidth] = Color.Transparent;
}
}
}
foregroundTexture = new Texture2D(device, screenWidth, screenHeight, false, SurfaceFormat.Color);
foregroundTexture.SetData(foregroundColors);
} |
| |
|
|
| |
| |
| Poster | : Anonymous | | Posts | : | | Country | : | | City | : |
| | | | Posted by Anonymous on 26/05/2012 at 07:53:36
| | | im pretty sure that you forgot about [] in declaration of terrainContour (in the begining of the code). I think you wrote int terrainContour instead of int[] terrainContour. Just add [] in declaration. If this doesn't help show all code. | |
|
|
| |
| |
| Poster | : Blackelfwolf | | Posts | : 3 | | Country | : new zealand | | City | : christchurch |
| | | | Posted by Blackelfwolf on 29/05/2012 at 23:38:16
| | | Thank you very much, now I can finish my code. I will remember this if I have future problems. You can always learn from your mistakes! | |
|
|