Adventure Game Studio | Forums

AGS Support => Beginners' Technical Questions => Topic started by: Racoon on Mon 18/11/2019 23:27:09

Title: Tried to set view, but it is not showing [SOLVED]
Post by: Racoon on Mon 18/11/2019 23:27:09
Hi Guys,

I wanted to add an animated object to a room. So I created the obejct oLight. I made a view, tried the preview and its working.

I added this to the room script:

function room_Load()
{
oLight.SetView(3);
}

function room_AfterFadeIn()
{
oLight.Animate(0, 5, eRepeat,  eNoBlock);
}

But when I start the game, it is still showing the cup image and not the view. If I rightclick on view 3 and search for usages it finds no usage..
Am I missing something obvious? Thanks for any helpful comments :)
Title: Re: Tried to set view, but it is not showing
Post by: Snarky on Tue 19/11/2019 00:14:40
For event handlers that are supposed to be called automatically when certain things happen, you can't just add them to the script, you have to link them up in the room event properties pane.
Title: Re: Tried to set view, but it is not showing
Post by: Racoon on Tue 19/11/2019 00:44:55
Hey Snarky,

Thanks for your reply! Sorry, but can you describe what you mean with link them up? I did go to the room events in the properties and put it in the room script there. Do you mean something else?
Title: Re: Tried to set view, but it is not showing
Post by: Cassiebsg on Tue 19/11/2019 01:54:30
Did you type it or did you click the ... button? Try clicking the button, if it doesn't take you to the start of the corresponding function check the that the names are exactly the same. Best way to fix this, if it's the problem, is to delete one of them and copy/paste the name of the other.
Title: Re: Tried to set view, but it is not showing
Post by: Khris on Tue 19/11/2019 04:22:07
Add a Display() call, like this:

function room_AfterFadeIn()
{
  Display("AfterFadeIn called");
  oLight.Animate(0, 5, eRepeat,  eNoBlock);
}


Do you see that in-game?
Title: Re: Tried to set view, but it is not showing
Post by: Crimson Wizard on Tue 19/11/2019 06:27:12
As an additional note -

Quote from: Racoon on Mon 18/11/2019 23:27:09
If I rightclick on view 3 and search for usages it finds no usage.

this won't show any usage if you are setting this view in script, only if you have a view set from the beginning in the editor, which currently is only possible with characters. So, this command has a limited purpose.
Title: Re: Tried to set view, but it is not showing
Post by: Racoon on Tue 19/11/2019 11:27:56
Okay, I know get what you mean with, that I cant just put it in the script. I finally got it working, yay. Its difficult as a beginner to figure some of these things out. Thanks everyone  :-D
Title: Re: Tried to set view, but it is not showing
Post by: Khris on Tue 19/11/2019 13:00:06
For reference, in case somebody else finds this thread, what did you do to fix it?
Title: Re: Tried to set view, but it is not showing
Post by: Racoon on Tue 19/11/2019 19:32:03
My mistake was, that I found the script for an animated object on the forums and thought it would just do to copy it to the room script. But for it to work you have to go to the room properties and for example if you want to use "room_AfterFadeIn" you have to click on the "..." next to "Enters room after fade-in" for the function to work.
Title: Re: Tried to set view, but it is not showing
Post by: Slasher on Tue 19/11/2019 19:50:32
That's a mistake many many people do...

Glad it's sorted ;)