Update ProgramDesign
parent
3ca7707ea1
commit
e7692454c6
@ -32,7 +32,14 @@ If you have twenty or thirty sprites, you will probably want to take the time to
|
||||
## Function to change mode
|
||||
You should create a function to change the game mode. We will place a call for this in a moment, but for now, we do something like:
|
||||
|
||||
* Clear all sprites: The sprite controller has a process for clearing all sprites that are duplicates of named sprites. Basically, anything on the screen gets removed.
|
||||
* Clear all sprites: The sprite controller has a process for returning all sprites that are duplicates of named sprites. We can use that to clear all the sprites like:
|
||||
```c#
|
||||
void ClearAllSprites()
|
||||
{
|
||||
foreach(Sprite one in mySpriteController.SpritesBasedOffAnything())
|
||||
one.Destroy();
|
||||
}
|
||||
```
|
||||
* Start Game: Change the background to whatever the game background is. Duplicate all the sprites you need for the game and place them in their starting positions.
|
||||
* Start Menu: Change the background to whatever the menu background image is. Duplicate all the menu sprite buttons and place them in their respective menu spots. (You should have menu buttons for things like “play”, “settings”, “high-scores”, and “exit”)
|
||||
* Start Settings: This is usually a special “menu” that has items like: “volume”, “speed”, etc.
|
||||
@ -44,7 +51,9 @@ The Game Tick function is where most of the work on your game goes. The Tick ha
|
||||
You usually check first to see if you are switching your mode to something else:
|
||||
```c#
|
||||
If(newmode != currentmode) ChangeMode(newmode);
|
||||
```
|
||||
And then, you have an if (or switch) block to process things depending on which mode you are in:
|
||||
```c#
|
||||
If(currentmode == GameMode.Playing) {
|
||||
CheckForKeypresses();
|
||||
CheckForChangeInLevel();
|
||||
@ -74,7 +83,7 @@ public void ExitClick(object sender, SpriteEventArgs e)
|
||||
If(sender is Sprite)
|
||||
{
|
||||
Sprite ExitSprite = (Sprite)sender;
|
||||
Sender.ChangeAnimation(2);
|
||||
Sender.ChangeAnimation(2); //What it looks like when it is clicked.
|
||||
NewGameMode = GameMode.Exiting;
|
||||
}
|
||||
}
|
||||
@ -84,7 +93,7 @@ public void ExitMouseOver(object sender, SpriteEventArgs e)
|
||||
If(sender is Sprite)
|
||||
{
|
||||
Sprite ExitSprite = (Sprite)sender;
|
||||
Sender.ChangeAnimation(1);
|
||||
Sender.ChangeAnimation(1); //Animation 1 has a glow around it and it is a different color
|
||||
}
|
||||
}
|
||||
public void ExitMouseLeave(object sender, SpriteEventArgs e)
|
||||
@ -92,7 +101,7 @@ public void ExitMouseLeave(object sender, SpriteEventArgs e)
|
||||
If(sender is Sprite)
|
||||
{
|
||||
Sprite ExitSprite = (Sprite)sender;
|
||||
Sender.ChangeAnimation(0);
|
||||
Sender.ChangeAnimation(0); //Animation 0 is "normal looking"
|
||||
}
|
||||
}
|
||||
```
|
Loading…
Reference in New Issue
Block a user