是否可以通过KineticJS设置对象偏移量,使其不移动?

//this moves it
img.offsetX(100);

//this also moves it
img.offset({x:100,y:0};


我试过了;

img.setoffset({x:100,y:100});


但这似乎无能为力?

我知道在创建图像时可以设置偏移量;

var newImg = new Kinetic.Image({
  x: x,
  y: y,
  image: imgObject,
  name: 'image',
  offset: {x:offX, y:offY}
})

最佳答案

位置=平移+偏移量。 TranslateX = X-offsetX。 TranslateY = Y-offsetY。因此,如果要创建一个看起来没有移动的对象的效果(尽管通过数字显示),则需要将偏移量添加到属性x和y。

关于javascript - 设置KineticJS图像的偏移量而不移动,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26694715/

10-13 09:34