Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: javinasty on Sat 19/01/2013 16:27:38

Title: change background
Post by: javinasty on Sat 19/01/2013 16:27:38
hello.

i'm sorry for my short mind, but i wonder if it ís possible set another background using the hotspots.
or if it is possible to load another room using the hotspots. for example making click on the drawn zone.

thanks a lot.
Title: Re: change background
Post by: Khris on Sat 19/01/2013 16:42:08
You need to do the tutorial and read the scripting section of the manual, otherwise you'll keep asking questions like this.

You're looking for hotspot events, how those work is explained here: Tutorial -> Starting off -> Part 3 - Hotspots and events

To change the room, call player.ChangeRoom(2); (http://www.adventuregamestudio.co.uk/manual/Character.ChangeRoom.htm)

To switch the background graphic, call SetBackgroundFrame(1); (http://www.adventuregamestudio.co.uk/manual/SetBackgroundFrame.htm)
(In order for this to work, you'll want to call SetBackgroundFrame(0) in the room's "before fadein" event, to turn off the background animation.)
Title: Re: change background
Post by: javinasty on Mon 21/01/2013 16:34:59
yes, i have to read all the tutorial. but i don't understand the way to work after read it.
when i wrote in the room1.asc flange:
function room_Load()
{
SetBackgroundFrame(0);
}
function hHotspot1_AnyClick()
{
GetBackgroundFrame()==2;
}
the first frame is stop, but the interaction with the hotspot drawn isn't work. and i don't know what i did wrong.
Title: Re: change background
Post by: Khris on Mon 21/01/2013 16:50:29
I told you exactly how to do it in my previous post.

GetBackgroundFrame() returns the current frame, it doesn't change it.
You basically wrote 0==2;
This will compile but obviously not do anything.

You need
Code (ags) Select
function hHotspot1_AnyClick()
{
  SetBackgroundFrame(1);
}


Note that background frames are numbered 0-4, so in order to show the second image, pass 1 as parameter.
Title: Re: change background
Post by: javinasty on Mon 21/01/2013 19:59:31
yes, but if i write GetBackgroundFrame(1);
appears a little window with this message:
there were compilation errors. see the output window for details.
and in the output window i can read:
wrong number of parameters in call to "GetBackgroundFrame"
Title: Re: change background
Post by: selmiak on Mon 21/01/2013 21:05:18
You need the SetBackgroundFrame(1); function, not GetBackgroundFrame(1); ;)
Title: Re: change background
Post by: javinasty on Tue 22/01/2013 09:25:10
ok, ok, it works.

yes, i wrote getbackground, instea of setbackground. and the loading room works too.

i want to apologize with khris for his patience. you make this site great.
thanks a lot.