Javascript 使用Paper.js检测当前旋转

Javascript 使用Paper.js检测当前旋转,javascript,game-physics,paperjs,Javascript,Game Physics,Paperjs,我正在和他们做一个小游戏, 但是我找不到Paperscript提供的任何方法来获得当前的轮换 我的项目组的 在下面的代码中,使用Q和E键旋转“circlegroup”应该会影响WASD导航,将项目移动到对象的“鼻子”当前指向的方向。我想我需要获得我的物品的当前轮换,以便 影响导航。Paper.js是否提供了实现这一点的方法 不,没有为每个对象存储旋转属性。您需要自己为每个对象或类定义它。查看包含在中的Paperoids游戏,以获取更详细的示例。现在实际上有一个旋转属性,如下所述: 为了实现这

我正在和他们做一个小游戏, 但是我找不到Paperscript提供的任何方法来获得当前的轮换 我的项目组的

在下面的代码中,使用Q和E键旋转“circlegroup”应该会影响WASD导航,将项目移动到对象的“鼻子”当前指向的方向。我想我需要获得我的物品的当前轮换,以便 影响导航。Paper.js是否提供了实现这一点的方法


不,没有为每个对象存储旋转属性。您需要自己为每个对象或类定义它。查看包含在中的Paperoids游戏,以获取更详细的示例。

现在实际上有一个旋转属性,如下所述:


为了实现这一点,您当前需要将#transformContent设置为false(也在上面的文章中描述)。这将很快成为默认行为。

在2017年偶然发现了这个问题。。。有一个Path.position属性

bigcircle = new Path.Circle({
  radius:10,
  fillColor: 'grey',
  position: (10, 20),
  selected: true
});

smallcircle = new Path.Circle({
  radius:5,
  fillColor: 'black'
});

var circlecontainer  = new Group({
  children:[smallcircle, bigcircle],
  position: view.center
});


var circlegroup = new Group({
  children: [circlecontainer]
});

function onKeyDown(event) {
  if(event.key == 'w') {
    circlegroup.position.y -= 10;
  }
  if(event.key == 'a') {
    circlegroup.position.x -= 10;
  }
  if(event.key == 's') {
    circlegroup.position.y += 10;
  }
  if(event.key == 'd') {
    circlegroup.position.x += 10;
  }
  if(event.key == 'q') {
      // hold down
    circlegroup.rotate(1);
  }
  if(event.key == 'e') {
      // hold downw
    circlegroup.rotate(-1);
  }
}