使用Paper.js检测当前旋转

 Jessie-GWU_552 发布于 2023-02-08 22:25

我正在用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 == 'q') {
      // hold down
    circlegroup.rotate(1);
  }
  if(event.key == 'e') {
      // hold downw
    circlegroup.rotate(-1);
  }
}

Jürg Lehni.. 7

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

https://groups.google.com/forum/#!topic/paperjs/Vwp5HbTo9W0

为了使其工作,您当前需要将#transformContent设置为false(也在上面的帖子中描述).这很快就会成为默认行为.

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有