小编PHe*_*rst的帖子

使用Paper.js检测当前旋转

我正在用Paper.js制作一个小型射击游戏,但是我无法找到Paperscript提供任何方法来获得我的一组项目的当前轮换.

在下面的代码中,使用Q和E键旋转"circlegroup"应该影响WASD导航,将项目移动到对象的"鼻子"当前指向的方向.我想我需要获取项目的当前轮换以影响导航.Paper.js提供了任何方法吗?

您可以在此处查看/编辑Papersketch

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 …
Run Code Online (Sandbox Code Playgroud)

javascript game-physics paperjs

4
推荐指数
1
解决办法
1440
查看次数

标签 统计

game-physics ×1

javascript ×1

paperjs ×1