How do I make earth rotate around the sun?

Forum Home Forum Home > Construct 2 General > How do I....?
 Post Reply Post Reply Page  12>
Author
9,810 Rep
Post Options Post Options   Quote Jailson Quote  Post ReplyReply Direct Link To This Post Topic: How do I make earth rotate around the sun?
    Posted: 28 Oct 2011 at 12:30am
I know, should not have missed some math classes. I am trying to make an object move around another, like earth move around the sun. But I don't know how to do it.

I need the object that is moving always face the object it is moving around.

Sorry for my poor english.

It would be nice if it were possible to rotate an object using it´s Image Point.
Apimenti Games
games.apimenti.com
Back to Top
6,791 Rep
Post Options Post Options   Quote Nickydude Quote  Post ReplyReply Direct Link To This Post Posted: 28 Oct 2011 at 12:35am
Take a look at the Pin example that comes with the latest build, that should help you.
Back to Top
9,810 Rep
Post Options Post Options   Quote Jailson Quote  Post ReplyReply Direct Link To This Post Posted: 28 Oct 2011 at 12:47am
I see. In that example the object rotates, then others move around. This is the only way?

I mean, I don´t want the object in the center rotates!
Apimenti Games
games.apimenti.com
Back to Top

Scirra Developer
78,501 Rep
Post Options Post Options   Quote Ashley Quote  Post ReplyReply Direct Link To This Post Posted: 28 Oct 2011 at 12:50am
The math you need is:

Set X to CenterX + cos(angle) * dist
Set Y to CenterY + sin(angle) * dist

CenterX/Y defines the center point of the circle, at the give angle, with a radius of 'dist'.

Math is actually really helpful in game creation, it's worth brushing up!

Edited by Ashley - 28 Oct 2011 at 12:51am
Back to Top
9,810 Rep
Post Options Post Options   Quote Jailson Quote  Post ReplyReply Direct Link To This Post Posted: 28 Oct 2011 at 2:22am
I know @Ashley! Math is good!

Thanks to your formula I was able to reach my goal. I would like to share what I just learned.

Here is an example of what I wanted to do. The project file (.capx) is also available!



Edited by Jailson - 28 Oct 2011 at 2:32am
Apimenti Games
games.apimenti.com
Back to Top

Moderator
28,650 Rep
Post Options Post Options   Quote Kyatric Quote  Post ReplyReply Direct Link To This Post Posted: 28 Oct 2011 at 12:45pm
Yes please Jailson, post the capx for this very example.
I added this topic in the FAQ.
Back to Top
9,810 Rep
Post Options Post Options   Quote Jailson Quote  Post ReplyReply Direct Link To This Post Posted: 28 Oct 2011 at 12:58pm
@Kyatric, the .capx is available at the example link. Below the demo.

But if you want it here, no problem, here it is.
Apimenti Games
games.apimenti.com
Back to Top

Moderator
28,650 Rep
Post Options Post Options   Quote Kyatric Quote  Post ReplyReply Direct Link To This Post Posted: 28 Oct 2011 at 1:04pm
Oh sorry, I didn't pay attention and missed the link.
Well at least it's here too now.

Good job, thanks for the example.
Back to Top
16,524 Rep
Post Options Post Options   Quote newt Quote  Post ReplyReply Direct Link To This Post Posted: 28 Oct 2011 at 3:52pm
Yeah that's a pretty standard formula, and can be applied in a ton of different ways.
..... wouldn't mind seeing it as an expression in C2.
Back to Top
749 Rep
Post Options Post Options   Quote deathofthedead Quote  Post ReplyReply Direct Link To This Post Posted: 11 Jan 2012 at 6:17pm
This is something I'd been trying to get to work, so this is very helpful. What would you need to do to let the player control rotation? I'm thinking of using this method for a targeting cursor that rotates around the main character when the player aims.
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down