Some help on my game
by Tyler Steele · in Torque Game Builder · 10/01/2007 (7:50 pm) · 3 replies
I am making a 2d game in TGB for a class at school. i need to know if i can set each character animations in their class (make a Mario class and set the then animations for attacking, walking, jumping etc.) then inherit it into a behavior so I have them in there ?
Second how do you make select screen?
third how do i switch levels after one person has beaten another?
is there anyway to animate in key mode?
Finally how do you differentiate between two controllers hooked into the same computer?
Second how do you make select screen?
third how do i switch levels after one person has beaten another?
is there anyway to animate in key mode?
Finally how do you differentiate between two controllers hooked into the same computer?
#2
11/11/2007 (5:22 pm)
* * * * *
#3
11/15/2007 (2:31 pm)
I think it only crashes if you're referencing an object in that scene. So, if Mario is a scene object, loading a new level from one of his member functions will delete him and the game will die because suddenly he's not there. In the example, you're calling a scene window function (not referencing anything in the scene graph nor the scene graph itself) so it doesn't crash. That's little comfort because 99% of the time you want to schedule it. Just wanted to offer $0.02.
Torque Owner Aaron K Murray
First of all, I recommend making functions that represent logical situations for your game. This will greatly help you in debugging, as well as planinng.
Partial example for your Mario situation, you could do something like...
Mario.showRunning();
Mario.showAttacking();
Mario.showJumping();
then do something like
function Mario::showRunning(%this) {
//add your code to use his running animations in here
}
---
Question 2: Make another Level using TGB. Call it something like SelectScreen.
Then you can load this level when you want to show the select screen.
Which leads to question 3...
---
Question 3:
This one is a little tricky. I didn't have much left using sceneWindow2D.loadLevel(%level) directly. Turns out that loadLevel disposes of the current level which typically causes your game to crash instantly.
I wrote my own LoadLevel() that handles this nicely:
function LoadLevel(%levelPath) { //%levelPath looks like "game/data/levels/OptionScreen.t2d"
if (%levelPath !$= "") {
sceneWindow2D.schedule(0, "loadLevel", expandFilename(%levelPath)); //can't just call loadLevel() directly because it deletes the current scene which is referenced in this scope and crashes TGB
} else {
error("Empty level path. Check your settings to make sure you are using the correct variable name.");
}
}
Hopefully this content is useful to someone using the search feature on the forums. We need more useful code in this TGB community.