VG:Backgrounds (VG2)

From MyProjectFun
Jump to: navigation, search

We add backgrounds in MyGame.cs under UserCode. This should be done in the CreateResources function, since that is where we want to load files into our game. To add a background, use the following code:

new Background("SpaceBackground", "mainBackground.png");

This lines says that we're making a new Background object named SpaceBackground, which uses the file mainBackground.png, which exists in my Art Assets folder under Maps.

Now that I have a background, I can tell my game to use it with the following code, which I could put in a level's initial behavior or the OnStart function in MyGame.cs.

This.Game.MasterMap = This.Game.FindBackGround("SpaceBackground");

This code tells the game to set the master map to the map named SpaceBackground. That should cover the basics of a background.

Personal tools
Namespaces
Variants
Actions
Navigation
Engineering
Game Design
Multimedia Production
VG Programming
Downloads
Toolbox