How to change animations when a sprite is moused over?
by Andrew H · in Torque Game Builder · 07/31/2011 (5:14 pm) · 3 replies
I am trying to make a menu screen, with all the buttons being sprites. I want them to change color (animation) when moused over. Is there a mouse event for when something is moused over, and if so, how can I use it to change animations?
About the author
I do everything for my game company. Including the legal stuff.
#3
07/31/2011 (10:11 pm)
This code should also do the trick, depending on how your code and animations are set up:if (!isObject(MouseOverAnimate))
{
%template = new BehaviorTemplate(MouseOverAnimate);
%template.friendlyName = "Mouse Over Animate";
%template.behaviorType = "GUI";
%template.description = "Play an animation when the mouse moves over this object. ";
%template.addBehaviorField(anim, "The animation to play", string, "test");
}
function MouseOverAnimate::onBehaviorAdd(%this)
{
%this.owner.setUseMouseEvents(true);
}
function MouseOverAnimate::onMouseEnter(%this, %modifier, %worldPos)
{
if ( isobject(%this.anim) )
%this.owner.playAnimation(%this.anim);
}
Employee Michael Perry
ZombieShortbus