2

我正在编写 HTML5 游戏,我完全按照教程进行,但出现错误“未捕获的类型错误:对象不是函数”。任何人都可以帮助我吗?

  var amplitude = 150;
  var period = 2000;
  animation = new Kinetic.Animation({
       // ERROR APPEARS HERE
      func: function (frame)
      {
      hook.setY(amplitude * Math.sin(frame.time * 2 * Math.PI / period));
      hook.setX(fisherGroup.getX());
      },
      node: shapesLayer
    });
  fisherGroup.on("mousedown", function(){
    animation.start();
  });

我创建了:hook = new Kinetic.Image()fisherGroup = new Kinetic.Group()以上这一段。

4

2 回答 2

0

Though I'm not positive without knowing more about the parameters of your set-up, I would guess that there may be a conflict with your variable name. Try changing the third line to:

var anim = new Kinetic.Animation({

Then on fisherGroup mousedown, call anim.start();

If you're using a framework that extends prototype and uses animation, that may cause an issue. Also, if you have animation set as a global (not declared with var), that may be an issue as well.

于 2012-11-12T13:35:18.543 回答
0

这与教程不完全一样,将其更改为:

 var animation = new Kinetic.Animation({function (frame) {
       hook.setY(amplitude * Math.sin(frame.time * 2 * Math.PI / period));
       hook.setX(fisherGroup.getX());
    },
    shapesLayer
});
于 2013-01-22T23:59:31.713 回答