conman06
Member
So, I'm working on a platformer. Each level has a door that leads to another room, and sometimes there are locked doors. The problem I'm confused about is why the door won't take me to the next room after the door has been unlocked. There is the object for a locked door (oDoorLocked), the key (oKey), and a regular door. I have a variable for oDoor (target_room) which is set in each oDoor instance, and a global variable for the oDoor which is +1 everytime a key has been collected by the player. The code for oDoorLocked is (Event is Key Press Up):
It basically tells the new oDoor instance to look the same as the locked door, and tells the game that target_room = L1s2 (the next room in the level.) In case you need it, the rooms are here: https://gyazo.com/79cc55951ec6ed8b61dec0732fefa0a7
In the transition object (oTransition), the code for switching between rooms is in the Animation End event:
That is activated when the script in oDoor creates an oTransition object in oDoor's Animation End event:
I know that the regular door works. I've tested that out before. I've been trying to fix this for a few days, so I'd be very grateful if someone could help me fix my mistake. If oyu need more info on my game, please feel free to ask. Thanks
GML:
if place_meeting(x,y,oPlayer) && global.Key = 1{
image_speed = 0;
with(instance_create_layer(x,y,"Walls",oDoor)){
image_xscale = other.image_xscale;
image_yscale = other.image_yscale;
image_index = 0;
visible = true;
target_room = L1s2};
instance_destroy()};
else sprite_index = sDoorLocked;
In the transition object (oTransition), the code for switching between rooms is in the Animation End event:
Code:
room_goto(oDoor.target_room);
Code:
with(instance_create_layer(x,y,"Transition",oTransition)){
image_xscale = 32;
image_yscale = 32;
image_index = 1;
visible = true;
}