Trying to get a 2d animation to start on tap
Hello,
I am trying to write script where the 2d animation starts on tap. As of right now I can only get the animation to go one frame per tap. Any help would be greatly appreciated. My code is here below:
// -----JS CODE-----
// Plays an animated sprite
//@input Component.SpriteVisual SnowmanSprite
var controllerProvider = script.SnowmanSprite.mainPass.baseTex.control;
var currentSnowmanFrame = 0;
controllerProvider.pauseAtFrame(currentSnowmanFrame);
function activateSnowmanAnimation () {
currentSnowmanFrame += 1;
currentSnowmanFrame = currentSnowmanFrame % controllerProvider.getFramesCount();
controllerProvider.pauseAtFrame(currentSnowmanFrame);
}
var touchEvent = script.createEvent("TapEvent");
touchEvent.bind(activateSnowmanAnimation)
Hey community, if you're wondering the question was answered here!