javascript - Detecting current rotation with Paper.js - Stack Overflow

I'm making a small shoot 'em up game with Paper.js,but I'm unable to find that Paperscr

I'm making a small shoot 'em up game with Paper.js, but I'm unable to find that Paperscript provides any way to get the current rotation of my group of items.

In the code beneath, rotating 'circlegroup' with Q and E keys, should affect the WASD navigation, moving the item in the direction that the 'nose' of the object is currently pointing at. I figure that I need to get the current rotation of my items in order to affect the navigation. Does Paper.js provide any way to do this?

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

I'm making a small shoot 'em up game with Paper.js, but I'm unable to find that Paperscript provides any way to get the current rotation of my group of items.

In the code beneath, rotating 'circlegroup' with Q and E keys, should affect the WASD navigation, moving the item in the direction that the 'nose' of the object is currently pointing at. I figure that I need to get the current rotation of my items in order to affect the navigation. Does Paper.js provide any way to do this?

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);
  }
}
Share Improve this question asked Dec 20, 2013 at 10:45 PHearstPHearst 7716 silver badges30 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 7

There actually is a rotation property now, as written about here:

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

In order for this to work, you currently need to set #transformContent to false (also described in the above post). This will soon bee the default behavior.

No, there's no rotation property stored per object. You'll need to define it per object or class yourself. Take a look at the Paperoids game included in the Github Repository for a more detailed example.

Stumbled upon this question in 2017... there is a Path.position property http://paperjs/reference/path/#rotation

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745266178a4619470.html

相关推荐

  • javascript - Detecting current rotation with Paper.js - Stack Overflow

    I'm making a small shoot 'em up game with Paper.js,but I'm unable to find that Paperscr

    4小时前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信