Animated backgrounds!

Started by marypotter3, Thu 22/09/2011 22:59:04

Previous topic - Next topic

marypotter3

Hey! How do I insert a animated background, but only if the player click on the hotspot first? And, after showing that animated background, how I change for the next room?

My code:
function hHotspot2_Look()
{
  if (change_bg)
  SetBackgroundFrame(0);
  if (change_bg2)
  SetBackgroundFrame(1);
  if (change_bg3)
  SetBackgroundFrame(2);
  if (change_bg4)
  SetBackgroundFrame(3);
  if (change_bg5)
  SetBackgroundFrame(4);
  else player.ChangeRoom(8);
}


function room_AfterFadeIn()
{

  SetBackgroundFrame(0);

Thanks!

Adrian

As Khris already mentioned, please check the manual:
http://www.adventuregamestudio.co.uk/manual/SetBackgroundFrame.htm

In room before fade in you set the Frame to 0, as you already did:

SetBackgroundFrame(0);

Then in function hHotspot2_Look() you set the background rotation back to normal behaviour by passing the frame as -1:

SetBackgroundFrame(-1);

Khris

Also note that you don't need 5 variables for this job.
Just change the type of change_bg to int, then store the number in there (since you're using frames 0-4, give it a default value of -1).

Now instead of setting change_bg2 to true, do this:
Code: ags
  change_bg = 1;


When it comes to setting the background:

Code: ags
  if (change_bg > -1) SetBackgroundFrame(change_bg);


Welcome to the wonderful world of variables :=

pcj

#3
But if you're already using the animated background feature to switch between versions of a background, you'll be unable to switch back to animating the background without it looking weird (since you only have 5 frames to work with).  At which point it may be better to use separate rooms for each background, or objects where needed instead of animated backgrounds.

Also, if you want to change the background for a room the character isn't presently in, you'll need to use a global variable and check it when the character loads that room.

Space Quest: Vohaul Strikes Back is now available to download!

SMF spam blocked by CleanTalk