Game Development Community

Temporarily disable t2dAnimatedSprite

by Nathan Hramits · in Torque Game Builder · 07/13/2005 (6:05 pm) · 5 replies

I'm working in script with a t2dAnimatedSprite that loops an animation endlessly. I would like to simply make it not visible for a while and then make it visible again. However, using the setVisible(false) call on it seems to do nothing. Is there some trick to this? Do I have to stop the animation somehow and then call setVisible(false) on it?

Example:
%object = new t2dAnimatedSprite() { sceneGraph = $mySceneGraph; };
%object.setSize($size);
%object.setGroup(1);
%object.setLayer(5);
%object.mount(%other);
%object.playAnimation(someAnimBlock);
%object.setVisible(false); //this line does nothing

(FYI, I changed the name of my objects/variables; I don't name things 'object' in practice)

About the author

Recent Threads

  • Velocity Units

  • #1
    07/13/2005 (7:19 pm)
    You could try .setEnabled(false);
    #2
    07/14/2005 (10:03 am)
    Good suggestion, but I tried that and it didn't work either. I've tried setEnabled(false) and setVisible(false) in the console, but the animation just keeps on looping. For now, I just have it play a different animation consisting of one transparent frame, which seems like kind of a hack...
    #3
    07/14/2005 (10:33 am)
    The reason setVisible() isn't working is because you mounted the sprite to another object. By default your mounted sprite will take on the properties of the mount. Thus, setVisible() does nothing because the sprite ignores it.
    #4
    07/14/2005 (11:01 am)
    Jason is spot on, if you don't want this functionality then set the "inheritAttributes" argument in the mount command to false.

    - Melv.

    Quote:
    inheritAttributes? Indicates whether the object inherits attributes from the object being mounted to. At the moment, the following atributes are inherited:-
    - Enabled, Visible and Flip.
    #5
    07/14/2005 (11:34 am)
    Thanks Jason & Melv, that fixed the problem. For the record, here's what the call now looks like for that mount:

    %object.mount(%other, "0 0", 0, false, true, true, false);

    -Nathan