Method invalid, not in dynamic (animated) mode
by Ian Riddell · in Torque 2D Beginner · 03/31/2014 (7:08 pm) · 0 replies
*** - SOLVED - *** I quickly solved this problem, but I'll leave this up anyways, in case someone else encounters it. But I don't want anyone to spend time working on this. This error was being thrown on the first pass through the animation sequence. Because it was checking for an animation before it had initialized the animation. I placed
%this.playAnimation("ToyAssets:TD_Wizard_WalkWest");
earlier in the code and the error went away. Thanks for letting me sort this out on the forum. :)
Hello Forum -
Long-time-Reader-First-time-Poster. Thanks for all the advice I have received from these forums, via Google.
I have been re-building the Ninja Platformer tutorial in Torque2DMIT, making adjustments as necessary.
I added a unique sprite (TD_Wizard) as an opponent for the ninja. I animated him. But a bizarre error msg pops up in the console every time I run. It seems to be throwing an error because it thinks that the wizard is not animated. Of course, I might be misreading the error msg.
First I'll post the console.log (just the important bit). There are quite a few echo debug calls in there. I'm sure that most readers can spot them.
<begin console.log>
OpenAL Driver Init
OpenAL Driver Init Success
call to createWizard
6525
Call to wizardClass::updateMovement
%this is 6525
call to setCurrentAnimation
%this is 6525
SpriteBase::getAnimation() - Method invalid, not in dynamic (animated) mode.
It was ELSE!
Call to wizardClass::updateMovement
%this is 6525
<end console.log>
All the references to 6525 are debug checks on the id no of %this. It is definitely the wizard object. And he IS animated when I run the program.
Here is the code from the wizards.cs file I made. There is vestigial code in there... and debug checks. Sorry if its bad form to include that stuff, but I wanted to be thorough.
<begin code>
function createWizard(%tempX, %tempY)
{
echo("call to createWizard");
%wizard = new Sprite()
{
class = "wizardClass";
size = "10 10";
image = "ToyAssets:TD_Wizard_CompSprite";
BodyType = dynamic;
Position = %tempX SPC %tempY;
moveLeft = true;
moveRight = false;
};
%wizard.setBodyType ( dynamic );
%wizard.setGatherContacts( true );
%wizard.setFixedAngle ( true );
%wizard.setCollisionCallback( true );
%wizard.createPolygonBoxCollisionShape();
//%wizard.createPolygonCollisionShape("1 3.5 2 0 3 -4.25 -3.5 -4.25 -3.5 3");
myScene.add(%wizard);
echo(%wizard);
%wizard.updateMovement();
}
function wizardClass::updateMovement(%this)
{
echo("Call to wizardClass::updateMovement");
echo("%this is "SPC %this);
%this.setCurrentAnimation();
%this.updateMovementSchedule = %this.schedule(1000,updateMovement);
}
function wizardClass::setCurrentAnimation(%this)
{
echo("call to setCurrentAnimation");
echo("%this is "SPC %this);
if(%this.getAnimation() $= "ToyAssets:TD_Wizard_WalkWest")
{
if(%this.getIsAnimationFinished())
{
%this.playAnimation("ToyAssets:TD_Wizard_WalkWest");
}
}
else
{
echo("It was ELSE!");
%this.playAnimation("ToyAssets:TD_Wizard_WalkWest");
}
}
<end code>
Although the functionality of the wizard animation is fine, it bothers me to see this in my console every time. I coped and pasted a lot of code that originated in the ninja platformer tutorial to bring this wazard sprite to life. I have made corrections/updates along the way.
Google brought me very little in reference to this error. I found references to some C++ code. But I am unfamiliar and couldn't decipher.
Advice?
I have to say, the pros who spend time in here answering noob questions (like mine) are heroes. Thanks!
%this.playAnimation("ToyAssets:TD_Wizard_WalkWest");
earlier in the code and the error went away. Thanks for letting me sort this out on the forum. :)
Hello Forum -
Long-time-Reader-First-time-Poster. Thanks for all the advice I have received from these forums, via Google.
I have been re-building the Ninja Platformer tutorial in Torque2DMIT, making adjustments as necessary.
I added a unique sprite (TD_Wizard) as an opponent for the ninja. I animated him. But a bizarre error msg pops up in the console every time I run. It seems to be throwing an error because it thinks that the wizard is not animated. Of course, I might be misreading the error msg.
First I'll post the console.log (just the important bit). There are quite a few echo debug calls in there. I'm sure that most readers can spot them.
<begin console.log>
OpenAL Driver Init
OpenAL Driver Init Success
call to createWizard
6525
Call to wizardClass::updateMovement
%this is 6525
call to setCurrentAnimation
%this is 6525
SpriteBase::getAnimation() - Method invalid, not in dynamic (animated) mode.
It was ELSE!
Call to wizardClass::updateMovement
%this is 6525
<end console.log>
All the references to 6525 are debug checks on the id no of %this. It is definitely the wizard object. And he IS animated when I run the program.
Here is the code from the wizards.cs file I made. There is vestigial code in there... and debug checks. Sorry if its bad form to include that stuff, but I wanted to be thorough.
<begin code>
function createWizard(%tempX, %tempY)
{
echo("call to createWizard");
%wizard = new Sprite()
{
class = "wizardClass";
size = "10 10";
image = "ToyAssets:TD_Wizard_CompSprite";
BodyType = dynamic;
Position = %tempX SPC %tempY;
moveLeft = true;
moveRight = false;
};
%wizard.setBodyType ( dynamic );
%wizard.setGatherContacts( true );
%wizard.setFixedAngle ( true );
%wizard.setCollisionCallback( true );
%wizard.createPolygonBoxCollisionShape();
//%wizard.createPolygonCollisionShape("1 3.5 2 0 3 -4.25 -3.5 -4.25 -3.5 3");
myScene.add(%wizard);
echo(%wizard);
%wizard.updateMovement();
}
function wizardClass::updateMovement(%this)
{
echo("Call to wizardClass::updateMovement");
echo("%this is "SPC %this);
%this.setCurrentAnimation();
%this.updateMovementSchedule = %this.schedule(1000,updateMovement);
}
function wizardClass::setCurrentAnimation(%this)
{
echo("call to setCurrentAnimation");
echo("%this is "SPC %this);
if(%this.getAnimation() $= "ToyAssets:TD_Wizard_WalkWest")
{
if(%this.getIsAnimationFinished())
{
%this.playAnimation("ToyAssets:TD_Wizard_WalkWest");
}
}
else
{
echo("It was ELSE!");
%this.playAnimation("ToyAssets:TD_Wizard_WalkWest");
}
}
<end code>
Although the functionality of the wizard animation is fine, it bothers me to see this in my console every time. I coped and pasted a lot of code that originated in the ninja platformer tutorial to bring this wazard sprite to life. I have made corrections/updates along the way.
Google brought me very little in reference to this error. I found references to some C++ code. But I am unfamiliar and couldn't decipher.
Advice?
I have to say, the pros who spend time in here answering noob questions (like mine) are heroes. Thanks!