Skip to content

Commit

Permalink
Merge pull request #292 from tzachshabtay/SplashDoc
Browse files Browse the repository at this point in the history
Splash screen- add doc and use background in demo
  • Loading branch information
tzachshabtay committed May 14, 2018
2 parents f56bfa6 + 04405f9 commit f7be897
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
28 changes: 28 additions & 0 deletions Docs/articles/splash-screen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Splash Screen

MonoAGS comes with a built-in simple splash screen that you can choose to use if needed.
The splash screen can be seen at the beginning of the demo game. It is a simple loading screen, showing a "Loading..." text (which can be changed to any custom text with any custom font/text color/etc) which gets smaller and then bigger in a loop while resources are loading.
When you load the splash screen you get a reference to the room so you can change its background or add any other desired graphics/sound assets, though notes that the text changes its size in a way designed to be independent of the framerate, as loading all of the resources might affect the framerate deeply, so adding your own custom animations to the splash screen might not show smoothly as in the rest of the game.

Here's an example in which we change the loading text, change the text color to blue and add a background:

```cs

var mySplashScreen = new AGSSplashScreen();
mySplashScreen.LoadingText = "Loading, Please Wait...";
mySplashScreen.TextConfig = new AGSTextConfig(brush: game.Factory.Graphics.Brushes.LoadSolidBrush(Colors.Blue));
var room = mySplashScreen.Load(game);

var splashBackground = game.Factory.Object.GetObject("Splash Background");
splashBackground.Image = await game.Factory.Graphics.LoadImageAsync("Rooms/Splash/bg.png");
room.Background = splashBackground;

await game.State.ChangeRoomAsync(room);

//...
//Load stuff here
//...
await game.State.ChangeRoomAsync(firstGameRoom);

```
2 changes: 2 additions & 0 deletions Docs/articles/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
href: repeat.md
- name: Effects
href: effects.md
- name: Splash Screen
href: splash-screen.md
- name: AGS Cheat Sheet
href: ags-cheat-sheet.md
- name: Advanced
Expand Down
5 changes: 5 additions & 0 deletions Source/Demo/DemoQuest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ private async Task loadSplashScreen(IGame game)
{
AGSSplashScreen splashScreen = new AGSSplashScreen();
Rooms.SplashScreen = splashScreen.Load(game);

var splashBackground = game.Factory.Object.GetObject("Splash Background");
splashBackground.Image = await game.Factory.Graphics.LoadImageAsync("Rooms/Splash/bg.png");
Rooms.SplashScreen.Background = splashBackground;

game.State.Rooms.Add(Rooms.SplashScreen);
Rooms.SplashScreen.Events.OnAfterFadeIn.SubscribeToAsync(async () =>
{
Expand Down

0 comments on commit f7be897

Please sign in to comment.