我正在用Paper.js做一个小射击游戏,但是我无法找到抄本提供任何方法来获得我的一组物品的当前轮值。
在下面的代码中,用Q键和E键旋转“圆圈组”应该会影响WASD导航,将项目移动到对象的“鼻子”当前所指向的方向。我认为,为了影响导航,我需要得到项目的当前轮转。Paper.js提供了这样做的方法吗?
你可以在这里看到/编辑报纸。
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);
}
}发布于 2013-12-20 16:43:44
不,每个对象都没有存储旋转属性。您需要自己为每个对象或类定义它。关于一个更详细的例子,请看一下Github储存库中包含的类纸游戏。
发布于 2014-01-05 12:41:52
现在实际上有一个旋转属性,如下所述:
https://groups.google.com/forum/#!topic/paperjs/Vwp5HbTo9W0
为了使其工作,您目前需要将#transformContent设置为false (在上面的文章中也有介绍)。这将很快成为默认行为。
发布于 2017-11-13 19:50:48
在2017年偶然发现了这个问题。有一个Path.position属性http://paperjs.org/reference/path/#rotation
https://stackoverflow.com/questions/20701819
复制相似问题