Positioning created actors on the circumference of a circle

Basically I have this actor that shoots lasers in the direction of the mouse. I know how to do that, but how do I position them so their centers are on the circumference of a circle?

Legendary Hoamaru

  • *
  • Posts: 1088
http://www.physicsforums.com/showthread.php?t=248191

Second post:

x = centerx + (distance * cos(angle))
y = centery + (distance * sin(angle))

This positions by top left, so subtract the half width and half height afterwards.

Alexin

  • *
  • Posts: 3130
Did you lock this topic by mistake?
"Find the fun"
alexin@stencyl.com

Greg

  • *
  • Posts: 1260
You didn't really tell us what isn't working, so it's tough to say.  But it looks like when you're creating your Actor, you start doing things with the x/y and width/height values, but you still have "self" selected - so it's operating on the Actor that spawned the other Actor.  Not sure if this is intentional.

Also, to make this work for games that are larger than the initial screen and allow for scrolling - you'll need to take this into account instead of comparing the mouse x/y values directly with the Actor's x and y values.