Trying to create a level loading system
by Kyle Keene · in Torque X 2D · 07/14/2009 (9:18 am) · 4 replies
Hi, I'm trying to make a system in my platformer where it loads the next scene, based on which door the player enters, and then if they go back through the door, they start where they entered the door in the last scene.
That is just a general idea of what I'm trying to do, but the first thing I tried doing was making a door that the player can enter and go to the next scene by pressing a certain key when colliding with the door. I couldn't even figure that out.
Now I have a general idea of what I need to do. I THINK what I need to do is check if the player collides with the door object, then check if the right key is pressed, and if both are true, load the next scene. I'm not completely sure about this but that's just what I'm thinking.
Sorry if this seems like a really odd question but I've been trying for a while to figure this out. I don't have much TX2D experience so if this seems really simple to you, it's not simple to me. If you have some suggestions on how to do this, whether it be a step by step guide or just giving me the plan on what I need to do, it would be much appreciated.
That is just a general idea of what I'm trying to do, but the first thing I tried doing was making a door that the player can enter and go to the next scene by pressing a certain key when colliding with the door. I couldn't even figure that out.
Now I have a general idea of what I need to do. I THINK what I need to do is check if the player collides with the door object, then check if the right key is pressed, and if both are true, load the next scene. I'm not completely sure about this but that's just what I'm thinking.
Sorry if this seems like a really odd question but I've been trying for a while to figure this out. I don't have much TX2D experience so if this seems really simple to you, it's not simple to me. If you have some suggestions on how to do this, whether it be a step by step guide or just giving me the plan on what I need to do, it would be much appreciated.
#2
You could set a flag such as inDoorway during the OnEnter event, and clear the flag for OnLeave, then when the user presses the button, just check the value of the flag to know if they are in the right place and thus should change scenes.
07/14/2009 (10:16 am)
The T2DTriggerComponent can be very helpful for determining when you collide with something. There are handy callbacks you can specify for the events OnEnter, OnStay, and OnLeave.You could set a flag such as inDoorway during the OnEnter event, and clear the flag for OnLeave, then when the user presses the button, just check the value of the flag to know if they are in the right place and thus should change scenes.
#3
Brian
07/14/2009 (10:50 am)
@Kyle - Also you'll probably want to look at the forum thread on changing scenes. Good luck!Brian
#4
07/14/2009 (11:43 am)
@Scott - I understand now what I need to do, I just don't know how to go about doing it. Theres still a whole lot I don't understand. If it's not to much trouble, could you give me step by step instructions on what I need to do? Like I said, I'm very new to TX2D... I feel like I learn better though by looking over and reading instructions, and since there aren't many tutorials that can help me out, it'd be much appreciated if you could help me.
Torque Owner Steve Wigmore
Default Studio Name
if the player enters the door ====>>>> then switch to the next level.
if the player does not enter the door ====>>>> then do nothing.
the problem here is how to define entering the doorway and hitting a button. So you have to expand that part of the flow.
you could either do a collision or a coordinate based system. seeing as you're really new to this, I'd say to stick with a simple solution first.
First, figure out the boundaries of your door (the coordinates of the four corners). Then write out a simple IF statement to determine if the player is within the doorway coordinates. IF they're within the doorway, THEN check to see if button is pressed. IF both are true, THEN switch to the next level.