xboxscene.org forums

Author Topic: Random Background  (Read 664 times)

Tru@ce

  • Archived User
  • Jr. Member
  • *
  • Posts: 66
Random Background
« on: March 09, 2005, 07:45:00 PM »

Hi  :) , credits to Outworld1 for this small code;

In default.xip/default.xap;

look for;

CODE
DEF myBackgroundList Group


and make it look like this;

CODE
DEF myBackgroundList Group
{

 children
 [
     DEF background0 Background{ skyColor 0 0 0 backdrop ImageTexture { url "background.xbx" }}
     DEF background1 Background{ skyColor 0 0 0 backdrop ImageTexture { url "background1.xbx" }}
     DEF background2 Background{ skyColor 0 0 0 backdrop ImageTexture { url "background2.xbx" }}
     DEF background3 Background{ skyColor 0 0 0 backdrop ImageTexture { url "background3.xbx" }}
     DEF background4 Background{ skyColor 0 0 0 backdrop ImageTexture { url "background4.xbx" }}
 ]
}

function loadBackground() {
var n = Math.round(Math.random() * (myBackgroundList.children.length() - 1));
myBackgroundList.children[n].isBound = true;  
}


then search for;

CODE
var currentTrack;


and paste this below;

CODE
var BeginUpdate;


then go to;

CODE
function UpdateMainMenu()
{
    if( m_nbuttons == 4 ) { Update4ButtonMainMenu(); }
    else  { Update3ButtonMainMenu(); }
}


and replace the function with this;

CODE
function setBeginUpdate()
{  
BeginUpdate = 1;
}

function UpdateMainMenu()
{      
  if (BeginUpdate == 1 )
  {
      loadBackground();
      BeginUpdate = 0;                
  }
  {
    if( m_nbuttons == 4 ) { Update4ButtonMainMenu(); }
   else  { Update3ButtonMainMenu(); }
  }
}


search for;

CODE
function OnYDown()


(or another)

and put this code in it;

CODE
      function OnYDown()
{
   setBeginUpdate();
   UpdateMainMenu();
}


Ciao  ;)



 <
Logged

BlackWraith

  • Archived User
  • Newbie
  • *
  • Posts: 48
Random Background
« Reply #1 on: March 17, 2005, 12:18:00 AM »

Nice post Tru@ce.  Thanks a lot

MerDeNoms
 <
Logged