Playing an animation on mouseRelease
by MichaelDom · in iTorque 2D · 09/17/2010 (2:18 pm) · 5 replies
I'm trying to play an animation onMouseUp, but it is giving me a cryptic error in the console.
The error: game/scripts/game.cs (239): Unable to find object: '' attempting to call function 'playAnimation'
function clickArea::onMouseUp(%this, %modifier, %worldPosition, %clicks
{
%clickArea.playAnimation("throwAnimation" @ %this);
}
Any help would be appreciated. :)
The error: game/scripts/game.cs (239): Unable to find object: '' attempting to call function 'playAnimation'
function clickArea::onMouseUp(%this, %modifier, %worldPosition, %clicks
{
%clickArea.playAnimation("throwAnimation" @ %this);
}
Any help would be appreciated. :)
#2
Unknown command playAnimation
Any help would be appreciated. It seems like playing an animation ought to be a fairly simple thing...
09/17/2010 (5:50 pm)
Nothing lol. Thought I needed it. I made the %this change you suggested but that generated this error: Unknown command playAnimation
Any help would be appreciated. It seems like playing an animation ought to be a fairly simple thing...
#3
You're going to need to give more information for me to assist some more :)
09/17/2010 (5:52 pm)
is the "clickArea" class object the thing you want to play an animation on? Is it a t2danimatedsprite?You're going to need to give more information for me to assist some more :)
#4
If by "on" you mean in the same location on the screen, then yes. But clickArea is not an animated sprite.
The animation's name is "throwAnimation".
I take it that that is part of my problem? And, I appreciate your willingness to assist me.
09/17/2010 (6:48 pm)
Sorry for the lack of info. I'm very new to Torque and it's been something of an adjustment. If by "on" you mean in the same location on the screen, then yes. But clickArea is not an animated sprite.
The animation's name is "throwAnimation".
I take it that that is part of my problem? And, I appreciate your willingness to assist me.
#5
What I'm assuming you want is an object that when you click on it, it plays a throw animation:
If you were to create t2dAnimatedSprite object, give it the class of "PlayerClass" the above code would make it play the "throwAnimation" animation when you clicked on it.
I think you will benefit from following the tutorials etc from TGB and then coming back to iTorque. This is especially important as iTorque doesn't really perform too well when you are working in script all the time. You'll want to up your C++ and ObjC skills to really get the best out of iTorque.
09/18/2010 (1:45 pm)
playAnimation needs to be called on a t2dAnimatedSprite. It doesn't just play an animation in an ad hoc fashion when you call it.What I'm assuming you want is an object that when you click on it, it plays a throw animation:
function PlayerClass::onMouseUp(%this, %modifier, %worldPosition, %clicks
{
%this.playAnimation("throwAnimation");
}If you were to create t2dAnimatedSprite object, give it the class of "PlayerClass" the above code would make it play the "throwAnimation" animation when you clicked on it.
I think you will benefit from following the tutorials etc from TGB and then coming back to iTorque. This is especially important as iTorque doesn't really perform too well when you are working in script all the time. You'll want to up your C++ and ObjC skills to really get the best out of iTorque.
Associate Craig Fortune
edit: oh, and what is the @ %this intending to do? Do you have differently suffixed throw animations?