Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Dany_the_penguin on Mon 15/07/2019 21:02:04

Title: Door/room problem still not fixed
Post by: Dany_the_penguin on Mon 15/07/2019 21:02:04
Facing issue with door, here is the problem cycle.
1. close door
2. walk off screen
3. walk back onto screen
4. door opened

This is the aftermath of a previous problem where the door would flicker opened and closed, somebody told me to use this to remedy it.

{
Code (ags) Select

function room_Load()
{
SetBackgroundFrame(0);
}


my current issue only happened as a result of this code, any alternative solutions?
Title: Re: Door/room problem still not fixed
Post by: eri0o on Mon 15/07/2019 21:19:35
Use an object for your door and change the graphics. The door graphic change will persist.
Title: Re: Door/room problem still not fixed
Post by: Dany_the_penguin on Mon 15/07/2019 21:23:42
how would I go about doing that?
Title: Re: Door/room problem still not fixed
Post by: Crimson Wizard on Mon 15/07/2019 21:27:09
Last time we talked you said you were changing room background when door opened/closed, are you still doing that?

If yes, then it's important to know that room background gets reset every time player leaves the room. So if you want to continue using that method you'll have to remember door state in a variable and restore it on room_Load ("before fade-in") event.

The alternative is to switch to using room objects, which remember their state and can have graphic changed in script (they have Graphic property).
Like -
Code (ags) Select
oDoor.Graphic = 100;
where oDoor is a script name of your door object and 100 is the opened door sprite.

Title: Re: Door/room problem still not fixed
Post by: Dany_the_penguin on Mon 15/07/2019 21:35:14
I still don't understand, as in how do I implement that?
Title: Re: Door/room problem still not fixed
Post by: Dany_the_penguin on Mon 15/07/2019 21:43:38
if 100 is closed or open, what would the alternative be?
Title: Re: Door/room problem still not fixed
Post by: Khris on Mon 15/07/2019 21:52:31
This is about sprite slots; draw the room background without the door, then create two sprites, one for the closed and one for the open door.
Assign the closed door sprite to the object in the editor, and when the player interacts with the door, change the door object's  .Graphic  property like shown, i.e. set it to the open door sprite's number.
Title: Re: Door/room problem still not fixed
Post by: Crimson Wizard on Mon 15/07/2019 22:20:56
Quote from: Dany_the_penguin on Mon 15/07/2019 21:43:38
if 100 is closed or open, what would the alternative be?

Anything you like! These are sprite numbers from your game, 100 is just a completely random example. Like Khris said above, you should have 2 sprites with opened and closed door. You probably already have at least on of them since you are painting on room background. Simply use their numbers.
Title: Re: Door/room problem still not fixed
Post by: Cassiebsg on Mon 15/07/2019 22:47:29
I like to use the BG showing the open door, and then just use one object with the closed door sprite.

Then all you have to do is:
oDoor.Visible= true; // door is closed

and

oDoor.Visible=false; // door is open

This saves me trouble of having to remember what the sprite number is.