Need help. Crashing when using %this.class in ParallaxObjectBehavior
by Nic Biondi · in Torque Game Builder · 09/07/2011 (12:59 pm) · 2 replies
Hello Gang! I hope you had a great long weekend!
I need a little help with my game. It's crashing when I add %this.class or %this.owner.class. In my test %this.owner.class results in "". I don't know why this is crashing but I think it might have something to do with the behavior. Anyone seen this before??
Thanks!!
-nic
function ParallaxObjectBehavior::onLevelLoaded(%this, %scenegraph)
{
%currPos = sceneWindow2d.getCurrentCameraPosition();
%this.oldPosX = getWord(%currPos, 0);
%this.oldPosY = getWord(%currPos, 1);
if(%this.owner.class=="bg") <--crashes here!
{
echo("sss");
}
}
I need a little help with my game. It's crashing when I add %this.class or %this.owner.class. In my test %this.owner.class results in "". I don't know why this is crashing but I think it might have something to do with the behavior. Anyone seen this before??
Thanks!!
-nic
function ParallaxObjectBehavior::onLevelLoaded(%this, %scenegraph)
{
%currPos = sceneWindow2d.getCurrentCameraPosition();
%this.oldPosX = getWord(%currPos, 0);
%this.oldPosY = getWord(%currPos, 1);
if(%this.owner.class=="bg") <--crashes here!
{
echo("sss");
}
}
#2
regarding "$=" ; I did know that there could be an issue with the string comparison, but as you said, that shouldn't explain the crashing. I usually use strcmp(x,y)==0 for my string comps though I don't know which one is more efficient.
I was able to fix the problem by making a reference to a function outside the method and that worked! I don't exactly know why though :D.
Thanks again for taking the time to reploy Justin!
It makes me feel good that I'm not alone out here!
cheers.
-nic
09/08/2011 (9:21 am)
Thanks for replying friend!regarding "$=" ; I did know that there could be an issue with the string comparison, but as you said, that shouldn't explain the crashing. I usually use strcmp(x,y)==0 for my string comps though I don't know which one is more efficient.
I was able to fix the problem by making a reference to a function outside the method and that worked! I don't exactly know why though :D.
Thanks again for taking the time to reploy Justin!
It makes me feel good that I'm not alone out here!
cheers.
-nic
Torque Owner Justin Proffitt
If changing the comparison operator doesn't fix it, then my only suggestion would be to make sure %this.owner gets loaded before it makes that check. In my experience, all crashes have been related to torque trying to write to something at the same instant it is reading it (e.g. ending levels then loading levels at the same time crashes). Since this is being called the very instant ParallaxObjectBehavior is loaded, I have no idea if %this.owner (whatever it may be) is being loaded at the same time or later.
Edit: When you say "crash", do you mean fatal exception kind of crash, or the script wont compile kind of crash?