Cannot unlink namespace" error -- help
by Jacob Vann · in Torque Game Builder · 02/25/2008 (9:57 pm) · 3 replies
Essentially, instead of adding the player sprite directly to my level, I'm needing to create a "locater" sprite that "marks" where the main sprite should be loaded by default. I made a static sprite and gave it a specific class name. When the locater object is loaded, I set some global variables, like so:
(Notice once I get the values I get rid of the sprite, since I don't need it)
Then, I call a function after the level has been loaded, and create a new player sprite at the $playerPosX and $playerPosY locations.
This works great on the first level I load, but when I move to the next level, something happens during the level load, and the jacobClass::onLevelLoaded function never gets called.
I have no idea what's causing those two errors. I don't have any class conflicts, and there is only one object with that class name in all of my test levels. Here's the locater sprite defined in the level file ...
I've tried giving the object a name, not giving the object a name, and nothing seems to work.
I'm hoping someone can help me. Thanks!
-Jacob
function jacobClass::onLevelLoaded (%this, %scenegraph) {
$playerInLevel = true;
$playerPosX = %this.getPositionX();
$playerPosY = %this.getPositionY();
%this.setVisible(false);
%this.schedule(50, delete);
}(Notice once I get the values I get rid of the sprite, since I don't need it)
Then, I call a function after the level has been loaded, and create a new player sprite at the $playerPosX and $playerPosY locations.
This works great on the first level I load, but when I move to the next level, something happens during the level load, and the jacobClass::onLevelLoaded function never gets called.
Compiling /Users/jvann/MyGames/MetalSeed/game/data/levels/B_Level.t2d... creating path /Users/jvann/MyGames/MetalSeed/game/data/levels/B_Level.t2d.dso Loading compiled script /Users/jvann/MyGames/MetalSeed/game/data/levels/B_Level.t2d. Namespace::unlinkClass - cannot unlink namespace parent linkage for jacobClass for t2dAnimatedSprite. Error: cannot change namespace parent linkage of jacobClass from t2dAnimatedSprite to t2dStaticSprite.
I have no idea what's causing those two errors. I don't have any class conflicts, and there is only one object with that class name in all of my test levels. Here's the locater sprite defined in the level file ...
new t2dStaticSprite() {
imageMap = "dude_framesImageMap";
frame = "0";
canSaveDynamicFields = "1";
class = "jacobClass";
position = "-37.250 56.500";
size = "12.000 12.000";
mountID = "7";
};I've tried giving the object a name, not giving the object a name, and nothing seems to work.
I'm hoping someone can help me. Thanks!
-Jacob
#2
Thanks for the response! Yep. One of the levels I was using an animated sprite for the locater, and the other adjacent level I was using a static sprite. Duh. Like all things, it's obvious in retrospect (and I was trying to blame my scripts!). Changing them both to staticSprites fixed the problem.
I ended up working around the problem by naming the object playerLocater and just adding some code in the sceneGraph::onLevelLoaded() to check for that object and set the globals. I was still getting errors when I went between rooms, but it the locater was being deleted correctly. Now it makes sense, since I made it work by not using the "jacobClass" functions.
Well, I don't want to hard code player position per level, because each t2d "level" is really one of up to 50 rooms in one larger world (think Metroid), and I'll have 8-10 worlds. Some levels will be 100x75, some will be 500x300 ... and I wanted to be able to drag and drop a little marker to show where the player will start if I dropped in the middle of the room, mostly so I can test a room on the fly. Really, the player will mostly enter a level from an adjacent one (and be loaded at the proper doorway), and I only really need to know where to put the player when I'm starting in that room (i.e., a save room or the beginning of a world).
I'm having a blast, and promise to really actually finish this game project this year. Honest. I have 3 aborted TGB/T2D projects going all the way back to the Early Adopter days, and things are so much easier now. :)
02/28/2008 (7:42 pm)
Kevin,Thanks for the response! Yep. One of the levels I was using an animated sprite for the locater, and the other adjacent level I was using a static sprite. Duh. Like all things, it's obvious in retrospect (and I was trying to blame my scripts!). Changing them both to staticSprites fixed the problem.
I ended up working around the problem by naming the object playerLocater and just adding some code in the sceneGraph::onLevelLoaded() to check for that object and set the globals. I was still getting errors when I went between rooms, but it the locater was being deleted correctly. Now it makes sense, since I made it work by not using the "jacobClass" functions.
Well, I don't want to hard code player position per level, because each t2d "level" is really one of up to 50 rooms in one larger world (think Metroid), and I'll have 8-10 worlds. Some levels will be 100x75, some will be 500x300 ... and I wanted to be able to drag and drop a little marker to show where the player will start if I dropped in the middle of the room, mostly so I can test a room on the fly. Really, the player will mostly enter a level from an adjacent one (and be loaded at the proper doorway), and I only really need to know where to put the player when I'm starting in that room (i.e., a save room or the beginning of a world).
I'm having a blast, and promise to really actually finish this game project this year. Honest. I have 3 aborted TGB/T2D projects going all the way back to the Early Adopter days, and things are so much easier now. :)
#3
Now your locater method makes sense. Good luck with the platformer game! I'm working on one right now myself. Mine is not a whole lot like Metroid besides the acrobatics. Think N and Knytt. Acrobatics and exploration.
02/29/2008 (4:52 am)
Glad to hear you found the problem and that you are having fun with TGB!Now your locater method makes sense. Good luck with the platformer game! I'm working on one right now myself. Mine is not a whole lot like Metroid besides the acrobatics. Think N and Knytt. Acrobatics and exploration.
Torque Owner Kevin James
There is both an animated sprite and a static sprite that have the "jacobClass". Perhaps you mistakenly placed an animated sprite as the "locater" instead of a static sprite.
Also try:
instead of:
The whole locater thing seems a bit round about. Why not just pass arguments in for player position based on what level is being loaded?