XNA loading/splash screen on game start - xna

I'm trying to have a loading screen that pops up as soon as you run that executable that launches the game, whilst the game loads I want to display an image on the desktop much like how Gamemaker allows you to have a loading image.
I've had a brief look around and most people want an image to be shown whilst they load content which is not what I want, or perhaps it is... =P
My guess would be to set the game window borderless at the start, load the splash screen, draw it, then begin all the main loading (Specifically loading DirectInput through SlimDX takes a while). However would this support having a transparent/irregular shaped image? E.G if I wanted a borderless circle to be displayed whilst the game loads, would that be possible?
Thanks.

It's very simple. Just implement System.Threading and you're done.
Here's how it works, first add:
using System.Threading;
to the top of your class, then add the following things:
//the enum for state types
enum GameState
{
Loading,
StartMenu
}
//Init our gameState enum as variable
GameState gameState;
protected override void LoadContent()
{
gameState = GameState.Loading;
spriteBatch = new SpriteBatch(GraphicsDevice);
device = GraphicsDevice;
Window.Title = "Your Window";
//Other stuff that you had here before, now go in LoadGame()
loadingscreen = Content.Load<Texture2D>("loading");
Thread bgLoad = new Thread(new ThreadStart(LoadGame));
bgLoad.IsBackground = true;
bgLoad.Start();
}
public void LoadGame()
{
//Loading stuff here
gameState = GameState.StartMenu; //or GameState.Playing
}
and then put a loading texture in your Content Project

If I understand you correctly, you essentially want to have a window opened that is not full screen that also lacks the regular border and buttons that accompanies a window.
I can't test this but this should be a good start.
Here!
I would start by creating a bare bones Game1 class that can track an image and keep track of time for a timer.
Later you could add logic that actually tracks the loading of assets in the main program.
To start I'd just test it for a fixed time like 3 seconds.

Related

Unity deploying to xcode in objective-C: how to delay launch screen in didFinishLaunching?

I have created a game in Unity and am deploying to an iPhone by building the project for Xcode and going from there. Unity wraps its projects up and generates the objective-C files in Xcode for you;
I have worked with Swift in the past and have always delayed my launch screens (I know this is bad practice but I am working with someone who would like the splash screen displayed for 3 seconds before the game instead just appearing briefly) by having the application sleep for a few seconds in the applicationDidFinishLaunching method. I need to know how to do this with a Unity project generated with objective-c-
I have tried putting [NSThread sleepForTimeInterval:6.0]; in the
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
function in my UnityAppController.mm file, and while this seems to be the right place the splash screen is still displayed for maybe a second.
How can I delay the splash in a unity project in Xcode?
Actually you can implement this request in the Unity itself.
Create a 2D canvas in your first scene, and make it over everything else like this:
Render Mode: Screen Space - Overlay
Change your splash screen image texture type to Sprite like this
Texture Type: Sprite (2D and UI)
Create an UI Image and assign above sprite as Source Image to cover all screen
Source Image: SplashScreenImage
Create a start script component into canvas object like this one
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class CanvasBehaviour : MonoBehaviour
{
public Image backgroundImage;
void Awake() {
StartCoroutine(RemoveBackgroundImage());
}
private IEnumerator RemoveBackgroundImage()
{
Debug.Log("Before Waiting 3 seconds");
yield return new WaitForSeconds(3);
backgroundImage.gameObject.SetActive(false);
Destroy(backgroundImage);
}
}
By doing this, after splash screen, user will only see the same image so he/she will not understand that anything changed.
Since you don't block the UI Thread by making sleep, you can show some basic animation in the canvas and/or prepare your scene behind the background image.

Xcode/Objective-C implementing a players turn toggle

I'm new to the whole VCM programming structure and more specifically to objective-c.
Right now i'm working on an iOS app that is like the game "connect 4." This Xcode project is my practice project that i've been using to play around/learn how to make iOS apps so there are several files and lots of commented out code, so Ill try my best to provide the necessary content from my project.
App State:
Right now I have a 10x10 grid of blue square/buttons. I'm still in the early stages of implementing the functionality of the game. Rather than making each square its own button, I created 10 frames and 10 buttons. Each row is a single button, which is broken up into 10 squares.
I currently have the squares change their color to red and become disabled once clicked. If I click multiple times.. the squares turn red when pressed. Heres a screenshot example run:
What Im wanting to do:
I want to build off of what I have, but not exactly sure how to keep track of which "players turn" it is. For example.. I want the first clicked square to turn red, representing player1's move. I want the second click to turn the button, say green, representing player2's move.. then the next move will be player 1's move.
I know Ill have to make sure the button is/was ENABLED and valid before switching which players turn it is.
How should I go about doing this? This is more of a general question, but I'll provide needed code snippets if necessary. Thanks!
In your .h file add an integer (variable)
int Turn = 1;
In your .m file you can do:
if(Turn == 1)
{
// Player one is playing
Turn = 2;
}
else if(Turn == 2)
{
// Player two is playing
Turn = 1;
}

JavaFX8: Application in fullscreen mode doesn't show focus on elements

I have the following problem: I would like to see which textfield or button is focused when I enter my multiscreen application in fullscreen mode. But for some reason, it is not showing the focus "glow" around for example a textfield. This is not a major problem, while it is focused the way I want it (requestFocus() does its job).
But it now gets annoying when I want to use AutoComplete TextField Completion from ControlsFX (How to implement AutoComplete TextField using ControlsFX), because the list is not shown in full screen mode.
I will clarify the situation with these screenshots:
How it is now in fullscreen mode:
How it should be (and how it is in non fullscreen):
To be clear: the problem doesn't only exist with AutoComplete TextField, but with every FXML element.
If I use the fullscreen mode from OSX itself, it works the proper way (It gives an error on the background). But I want the application to start in fullscreen mode.
This the code from my Main.java:
public class Main extends Application {
//Get the screenscontroller instance
octocash.GUI_Screens.ScreensController mainContainer = octocash.GUI_Screens.ScreensController.getInstance();
//Get the configuration instance
Configuration initApp = Configuration.getInstance();
//Create an object of Functions to establish a database connection
public static Functions databaseConnection = new Functions();
//Create a stage object to hold the primarystage
public static Stage primaryStage;
#Override
public void start(Stage stage) throws Exception {
primaryStage = stage; //set the primary stage
databaseConnection.DB_Connect(); //establish database connection
//Load the initial screen (lockscreen)
mainContainer.loadScreen(Configuration.lockScreen, Configuration.lockScreenFile);
mainContainer.setScreen(Configuration.lockScreen);
Group root = new Group(); //Create a group to hold all other screens
root.getChildren().addAll(mainContainer); //Add all Screenscontroller screens to the Group
Scene scene = new Scene(root); //set the group to the scene
stage.getIcons().add(new Image("file:src/octocash/images/octo_cash_logo.png")); //add a menubar icon
stage.setTitle("OctoCash Development"); //set the window name
stage.setScene(scene); //set the scene
stage.setFullScreen(true); //full screen without borders (no program menu bars)
stage.setFullScreenExitHint(""); //Don't show "Press ESC to exit full screen"
//stage.setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); //DO NOT TURN ON UNLESS YOU CREATED ANOTHER METHOD TO EXIT THE PROGRAM
stage.show(); //show the application
}
/**
* #param args the command line arguments
*/
public static void main(String[] args) {
launch(args); // start the application
}
}
As you can see, I am using a ScreensController, which is basically a StackPane with all of the screens in it.
I hope the question is clear to you all.
Any help is greatly appreciated!
I figured out that this is an error in Java JDK 8u25. I have now updated to Java JDK 8u40, and this solves the problem. Also, I have tested the fullscreen focus on Windows and Linux, and there it also works. So if you are having the same problem, just update your JDK.

XNA how to check if the game window cross "X" is clicked

Hi am making a game for Windows PC using XNA and I want to check when the game window cross "X" is clicked, so I can instead draw a menu and do other stuff instead of the game closing.
So yea, how can I check when the cross is clicked.
Thanks!
There is nothing special needed for XNA, you can do this the same way as you could without it.
In your Initialize or LoadContent method need to find the Windows form reference your game is using, and add a Closing event to it.
Form form = Form.FromHandle(Window.Handle) as Form;
form.FormClosing += OnClosing;
Then using this OnClosing method, you can cancel the close event, and run your own menu screen. (Probably by changing the game state and drawing something else)
void OnClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
ShowMenuScreen();
}

Alternativa3d Change Resolution for iOS in Flash Builder

I have a problem. I did the first example (Alternativa for dummies part I) and it runs fine but only fills 1/4 of the screen when using Air for iOS. How can I change the resolution?
Here is a screenshot:
http://tinypic.com/r/34yo86q/6
Are you using this code to set up the camera?
camera.view= new View (stage.stageWidth, stage.stageHeight);
The problem comes from the fact that those values are not constant during the whole life of the app. When the app starts, it's possible that the stage resizes, and thus you wouldn't be getting the right values.
First you could set those properties (I do this in 99% of my AS3 projects).
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
Then add an event listener for stage resize, and in the handler write the stageWidth and stageHeight values to some vars you could then use to init Alternativa's camera. Or maybe wait for the event to trigger before setting up the camera.
stage.addEventListener(Event.RESIZE, checkSize);
The handler
public function checkSize(e:Event):void {
realWidth = stage.stageWidth;
realHeight= stage.stageHeight;
}
Here is Adobe's documentation on the event, with examples on how to use it.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Stage.html#event:resize

Resources