我正在用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(也在上面的帖子中描述).这很快就会成为默认行为.