mirror of
https://github.com/konvajs/konva.git
synced 2025-08-23 16:34:29 +08:00
isRunning
function for Sprite
object
This commit is contained in:
parent
86178185bc
commit
53ac9329de
@ -136,6 +136,15 @@
|
||||
this.anim.stop();
|
||||
clearInterval(this.interval);
|
||||
},
|
||||
/**
|
||||
* determine if animation of sprite is running or not. returns true or false
|
||||
* @method
|
||||
* @memberof Kinetic.Animation.prototype
|
||||
* @returns {Boolean}
|
||||
*/
|
||||
isRunning: function() {
|
||||
return this.anim.isRunning();
|
||||
},
|
||||
_updateIndex: function() {
|
||||
var index = this.frameIndex(),
|
||||
animation = this.getAnimation(),
|
||||
|
@ -72,6 +72,48 @@ suite('Sprite', function() {
|
||||
};
|
||||
imageObj.src = 'assets/scorpion-sprite.png';
|
||||
});
|
||||
|
||||
test('check is sprite running', function(done){
|
||||
var imageObj = new Image();
|
||||
imageObj.onload = function() {
|
||||
var stage = addStage();
|
||||
var layer = new Kinetic.Layer();
|
||||
|
||||
|
||||
var sprite = new Kinetic.Sprite({
|
||||
x: 200,
|
||||
y: 50,
|
||||
image: imageObj,
|
||||
animation: 'standing',
|
||||
animations: {
|
||||
standing: [
|
||||
0, 0, 49, 109,
|
||||
52, 0, 49, 109,
|
||||
105, 0, 49, 109,
|
||||
158, 0, 49, 109,
|
||||
210, 0, 49, 109,
|
||||
262, 0, 49, 109
|
||||
]
|
||||
},
|
||||
frameRate: 50,
|
||||
draggable: true,
|
||||
shadowColor: 'black',
|
||||
shadowBlur: 3,
|
||||
shadowOffset: {x: 3, y:1},
|
||||
shadowOpacity: 0.3
|
||||
});
|
||||
|
||||
layer.add(sprite);
|
||||
stage.add(layer);
|
||||
assert.equal(sprite.isRunning(), false);
|
||||
sprite.start();
|
||||
assert.equal(sprite.isRunning(), true);
|
||||
sprite.stop();
|
||||
done();
|
||||
};
|
||||
imageObj.src = 'assets/scorpion-sprite.png';
|
||||
});
|
||||
|
||||
test.skip('can change frame rate on fly', function(done){
|
||||
var imageObj = new Image();
|
||||
imageObj.onload = function() {
|
||||
|
Loading…
Reference in New Issue
Block a user