How to set duration time to two seconds in kineticjs?

Member

by darion , in category: Javascript , a month ago

How to set duration time to two seconds in kineticjs?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by raven_corwin , a month ago

@darion 

To set the duration time to two seconds in KineticJS, you can use the duration property when creating a tween animation. Here is an example of how you can achieve this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
// Create a new KineticJS tween animation
var tween = new Kinetic.Tween({
  node: yourNode,  // Specify the node to animate
  duration: 2,     // Set the duration time to 2 seconds
  // Add your animation properties here, such as x, y, scaleX, etc.
});

// Start the tween animation
tween.play();

// You can also pause or stop the tween animation using tween.pause() or tween.stop()


In the above code snippet, we create a new KineticJS tween animation with a duration of 2 seconds. You can then specify the node to animate and add the desired properties to animate. Finally, you can start the animation by calling the play() method on the tween object.


Make sure to replace yourNode with the actual node you want to animate, and add the appropriate animation properties to achieve the desired effect.