Skip to content

Commit

Permalink
✨ Add splash screen
Browse files Browse the repository at this point in the history
  • Loading branch information
schonstal committed Aug 24, 2016
1 parent 565fceb commit e6027d2
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 27 deletions.
Binary file added assets/images/splash.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sounds/bading.wav
Binary file not shown.
2 changes: 1 addition & 1 deletion source/Main.hx
Expand Up @@ -12,7 +12,7 @@ class Main extends Sprite
{
var gameWidth:Int = 320; // Width of the game in pixels (might be less / more in actual pixels depending on your zoom).
var gameHeight:Int = 240; // Height of the game in pixels (might be less / more in actual pixels depending on your zoom).
var initialState:Class<FlxState> = StartupState; // The FlxState the game starts with.
var initialState:Class<FlxState> = SplashState; // The FlxState the game starts with.
var zoom:Float = -1; // If -1, zoom is automatically calculated to fit the window dimensions.
var framerate:Int = 60; // How many frames per second the game should run at.
var skipSplash:Bool = true; // Whether to skip the flixel splash screen that appears in release mode.
Expand Down
24 changes: 0 additions & 24 deletions source/MenuState.hx

This file was deleted.

4 changes: 2 additions & 2 deletions source/PlayState.hx
Expand Up @@ -60,7 +60,7 @@ class PlayState extends FlxState
FlxG.save.data.musicVolume = 0.8;
}
if (FlxG.save.data.sfxVolume == null) {
FlxG.save.data.sfxVolume = 0.8;
FlxG.save.data.sfxVolume = 0.6;
}
FlxG.sound.volume = 1;

Expand Down Expand Up @@ -239,7 +239,7 @@ class PlayState extends FlxState
if (player.health >= 100) player.health = 100;
FlxG.camera.flash(0xccffffff, 0.5, null, true);
health.kill();
FlxG.sound.play("assets/sounds/player/heal.wav", 0.6);
FlxG.sound.play("assets/sounds/player/heal.wav", 0.5 * FlxG.save.data.sfxVolume);
});

var laserSprite:FlxObject;
Expand Down
46 changes: 46 additions & 0 deletions source/SplashState.hx
@@ -0,0 +1,46 @@
package;

import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.text.FlxText;
import flixel.ui.FlxButton;
import flixel.util.FlxTimer;

class SplashState extends FlxState
{
var splash:FlxSprite;
var bg:FlxSprite;

override public function create():Void {
FlxG.mouse.useSystemCursor = true;
FlxG.sound.muteKeys = null;
if (FlxG.save.data.invertControls == null) FlxG.save.data.invertControls = true;

bg = new FlxSprite();
bg.makeGraphic(FlxG.width, FlxG.height, 0xff000000);
add(bg);

splash = new FlxSprite();
splash.loadGraphic("assets/images/splash.png");

FlxG.sound.play("assets/sounds/bading.wav");
new FlxTimer().start(0.25, function(t):Void {
add(splash);
new FlxTimer().start(2, function(t):Void {
remove(splash);
new FlxTimer().start(0.75, function(t):Void {
FlxG.switchState(new StartupState());
});
});
});
}

override public function destroy():Void {
super.destroy();
}

override public function update(elapsed:Float):Void {
super.update(elapsed);
}
}

0 comments on commit e6027d2

Please sign in to comment.