gpt4 book ai didi

javascript - 使用 Paper.js 检测当前旋转

转载 作者:搜寻专家 更新时间:2023-11-01 05:23:27 25 4
gpt4 key购买 nike

我正在用 Paper.js 制作一个小型射击游戏,但我找不到 Paperscript 提供任何方式来获取当前旋转我的项目组。

在下面的代码中,使用 Q 和 E 键旋转“circlegroup”应该会影响 WASD 导航,将项目移动到对象“ Nose ”当前指向的方向。我认为我需要获取我的项目的当前轮换,以便影响导航。 Paper.js 是否提供任何方法来执行此操作?

You can see/edit the Papersketch here

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);
}
}

最佳答案

现在实际上有一个旋转属性,如这里所写:

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

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

关于javascript - 使用 Paper.js 检测当前旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20701819/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com