Different transitions for different rooms

Started by blenderhead, Sun 08/09/2013 21:46:47

Previous topic - Next topic

blenderhead

Is it possible to have certain transitions for certain rooms ? i'd like to use the fade transition for changing  but i have a smart phone item that the player always has and uses throughout the game, the phone is a room that i'd like to transition to instantly, i know you can change the transitions using code, but i can't seem to get it how i want it.

Thanks

Gilbert

You may use SetScreenTransition() or SetNextScreenTransition() for this.
For your case I think SetNextScreenTransition() is probably a better choice.
Just before you need to change to the room with the phone, use:
Code: ags
SetNextScreenTransition(eTransitionInstant);


blenderhead

Thanks for the reply, i should have been clearer in my post i've tried these the problem is the phone is in the inventory and can be accessed by the player at any point so for example if i have a room with a door that leads to another room i want the player to be able to either leave the room using the door with a fade transition or use the phone with an instant transition.

Slasher

#3
Quotei want the player to be able to either leave the room using the door with a fade transition or use the phone with an instant transition.

You could have it where you use the inventory item (iphone) on yourself.

In the characters events panel select 'Use inventory on character'

You can then add this (example):

Code: ags

if(player.ActiveInventory==iphone && player.Room==3) // change player to characters script name etc etc and by donating: player.Room==[n] means you can use it in any room and just change Room number [n] the player is in.
{ 
player.ActiveInventory=null; // Takes away the iphone inv cursor when transported to next Room if required
SetNextScreenTransition(eTransitionInstant); 
player.ChangeRoom(3, 168, 254);// Set Room and co-ords to change to here
}


Or walk through the door for Fade instead.

blenderhead

Thanks slasher thats a nice idea though i'd rather have it that you can simply click on the phone, but i'll use this if i cant find another solution.

Khris

It doesn't really matter what event is used or what the function is called or whatever, as long as you call SetNextTransition() right before the room change to the "phone room".
So how did you try the command, and how did it fail? Like you already said, you need to be clearer.
And btw, the fact that the phone can be accessed in any room isn't an issue at all; for instance when you close the phone and go back to the game, you simply use
Code: ags
  SetNextScreenTransition(eTransitionInstant);
  player.ChangeRoom(player.PreviousRoom);

It will work just fine, as long as you don't change the game's default transition.

Slasher

#6
I suppose you could do that by stating it in Global Rep Exec but you will need to amend for every room that the player is in and what room he goes to.

This way whenever you select it (hand) in your inventory the events will run.

Code: ags
if(player.ActiveInventory==iphone && player.Room==3) // change player to characters script name etc etc and by donating: player.Room==[n] means you can use it in any room and just change Room number [n] the player is in.
{ 
player.ActiveInventory=null; 
gInventory.Visible=false; 
SetNextScreenTransition(eTransitionInstant); 
player.ChangeRoom(3, 168, 254);// Set Room and co-ords to change to here
}


and of course to go back to previous room (as Khris stated) use:
Code: ags
SetNextScreenTransition(eTransitionInstant);
 player.ChangeRoom(player.PreviousRoom);





Khris

#7
The phone should be implemented as a GUI button, but that's beside the point.
One should only use workarounds when the straightforward way fails. If the phone is just a regular inv item, one only needs to put one or two additional lines in on_mouse_click (assuming that inv item clicks are handled manually).
Also, why the Room check?

blenderhead: please ignore the advice in the post above this one for now, it'll only be confusing.

blenderhead

Thanks for the help guys i think i've got it
Quotewhen you close the phone and go back to the game
You're right Khris i should have been more clearer on what i had tried, leaving the room (phone) wasn't the problem but i couldn't use SetNextScreenTransition(eTransitionInstant); in the previous room as this would affect the transition as using the door too, so i the set SetScreenTransition in the phone room before fade in but that didn't work either.

But it seems to be working now ive put this in global script

Code: ags
 function iPhone_Interact()
{
player.ChangeRoom(12);
SetScreenTransition(eTransitionInstant);
} 


and put a SetNextScreenTransition(eTransitionfade); in the room_leave function in the phone room this seems to solve it, i didn't think to use the global script as i'm new to scripting and haven't used the global script much.




blenderhead

Thank you slasher i can see how this would work but i think Khris is right as i seem to have found a simpler solution unless there's something i'm missing.

Khris do you mean to access the phone it should be a GUI button instead of an inventory item ?
I don't know why i didn't think of this, perhaps because i originally had the phone as a usable item.
Thank you.

Khris

What you did seems to work because even though you put the ChangeRoom() command first, it is called only after the function has ended. So you're changing the transition to instant permanently, for all subsequent room changes, then change to the phone room.
Then you set the next (and only the next) transition to fade when the player leaves the phone room.
So this will a) make the transition from phone room back to actual room fading (which I assumed isn't what you want) and b) leave every subsequent transition instant (which is also not what you want)

Again:
-in the game settings, set the transition to the one you want from room to room
-whenever you want a different transition, use SetNextScreenTransition() in the same function that contains player.ChangeRoom().
-according to what you wrote, you will only need this two times, once when the player interacts with the phone, and possibly a second time when the player leaves the phone room.

blenderhead

Ah right i get it now, yes it was fading from the phone which i didnt want.

i have it now, thanks again.

SMF spam blocked by CleanTalk