Door/room problem still not fixed

Started by Dany_the_penguin, Mon 15/07/2019 21:02:04

Previous topic - Next topic

Dany_the_penguin

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

function room_Load()
{
SetBackgroundFrame(0);
}


my current issue only happened as a result of this code, any alternative solutions?

eri0o

Use an object for your door and change the graphics. The door graphic change will persist.

Dany_the_penguin


Crimson Wizard

#3
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
oDoor.Graphic = 100;

where oDoor is a script name of your door object and 100 is the opened door sprite.


Dany_the_penguin

I still don't understand, as in how do I implement that?

Dany_the_penguin

if 100 is closed or open, what would the alternative be?

Khris

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.

Crimson Wizard

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.

Cassiebsg

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.
There are those who believe that life here began out there...

SMF spam blocked by CleanTalk