Intermediate C# dev here. Trying to transition into game programming by writing a simple Simon clone (private learning only, I do not own any copyrights or intend to distribute/sell) and I'm stuck.
Here's a link to the full code thus far: Simon
The problem lies in the PlayTile()
method below:
private void PlayTile(Button btnColorOfTile, Color lightedTileColor, SoundPlayer tileSoundPlayer, Color originalTileColor)
{
// ***BUG03***
TilePress(btnColorOfTile, lightedTileColor, tileSoundPlayer);
// Small pause so tile can be lit before instantly changing back
Thread.Sleep(SLEEP_TIME);
TileRelease(btnColorOfTile, originalTileColor, tileSoundPlayer);
// Small pause between each tile play so that you can distingish multiple plays of the same tile.
Thread.Sleep(SLEEP_TIME);
}
This is supposed to "light" up the tile by changing the BackColor
property, pause for a half second (SLEEP_TIME
is set to 500ms) while playing the tile's sound, and change the BackColor
back to the normal color.
The sound plays properly with the pause and everything, but the tiles are not changing color. I change the BackColor
property in TilePress()
and change it back in TileRelease()
which is called in the MouseUp and MouseDown for the tile's event handlers and it works just fine.
Any ideas why PlayTile()
is working for sound but not changing the BackColor
property?
Also, if you see any glaring mistakes in the code, please let me know. This is all about learning for me so constructive criticism is desired.
Thanks in advance for any help!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…