@hal.littel
You can track the animation frame count in KineticJS by using the frame property of the animation object. Here's an example of how you can do this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
// Create a new stage
var stage = new Kinetic.Stage({
container: 'container',
width: 500,
height: 500
});
// Create a new layer
var layer = new Kinetic.Layer();
// Create a new shape
var circle = new Kinetic.Circle({
x: stage.getWidth() / 2,
y: stage.getHeight() / 2,
radius: 50,
fill: 'red',
stroke: 'black',
strokeWidth: 2
});
// Add the shape to the layer
layer.add(circle);
// Add the layer to the stage
stage.add(layer);
// Create a new animation
var anim = new Kinetic.Animation(function(frame) {
// Log the frame count
console.log(frame.frame);
}, layer);
// Start the animation
anim.start();
|
In this example, we create a new KineticJS animation that logs the frame count to the console on every frame. Inside the animation function, you can access the frame count using frame.frame.