Jump to content

main menu background


gab
 Share

Recommended Posts

  • 10 months later...

Agree. Can't we have them all, and have the main menu backgrounds alternately change whenever we start a game? Forgive my ignorance on how simple or complex that suggestion is, programming-wise.

The code supported multiple backgrounds for quite some time. It might need some slight adjustments, but it shouldn't be a lot of work. If LordGood could give us some layers to show that would help a lot.
Link to comment
Share on other sites

  • 5 months later...

I made it a bit easier to add new backgrounds, and you can decide which layers tile and which don't. Currently, you can add up to 5 layers for a background set, if you want more, it's easy to change. To add a background set, you just need to add two small files. See the files in http://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/gui/pregame/backgrounds .

First, you have to make a .xml file in that directory, similar to http://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/gui/pregame/backgrounds/hellenes.xml , there you define a sprite for every image layer. Every sprite must have a unique name, and define what texture to be used. The first sprite is an example of a tiled sprite, the other two are non-tiled. Best is to at least make the background tiled, so that people with big screens get a nice view. Foregrounds can be tiled or non-tiled. A non-tiled sprite should always have a 2:1 image resolution. Else there will be some strange stretching.

Then, after the sprites are defined, you need to add a simple JS file, similar to http://trac.wildfiregames.com/browser/ps/trunk/binaries/data/mods/public/gui/pregame/backgrounds/hellenes.js . That JS file defines the order of the layers (the background should be placed at the top). You also define whether that layer is tiled and which sprite to use for the layer.

The offset defines the layer motion as a function of time and the screen width. The Math.cos function makes it oscillate to the left and right (note that for tiled layers, you don't need oscillation, and you can just keep scrolling to one side). An offset of 0 would make the image centred on the screen. The constants are there to define the speed of oscillation, the width of the oscillation, and the average offset to the screen centre.

I hope this makes it easy enough to add backgrounds in a way the artist (and not the programmer) likes.

EDIT: if you add backgrounds, and you want to test them, it's obviously annoying if they appear only randomly. The best way to stop loading other backgrounds is by giving the other JS files a different extension (f.e. "*.js.backup"). That way, they won't be read.

  • Like 3
Link to comment
Share on other sites

  • 1 year later...
  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...