This works if you make something like a gun with a big laser scope attached to it and make sure that the central rotation point (the little plus) is in the handle of the gun.
The way it works is it calculates the ratio of the difference in X and Y values, then uses them to make a right triangle. By dividing one by the other and taking the arc-tangent, it produces the angle that the thing needs to be rotated by in radians. Multiply that by [180/Math.PI] and you have it in degrees.
I also had a problem where this would only work if the mouse was to the right of the symbol. The first two "if" statements fix that.
I hope this helps someone! You can use it, but just make sure you tell me so that I know it was useful!
Thx. Also, that "_root.awesome.txt" line is for something I was using for testing something. I had a dynamic text box to show me the _rotation of the object.
Also, I'm a newbie flah person also but I still think this can be useful. I think I'm gonna use it in my first game ever, which I'll probably post here.
This is alright but not so efficient, better ways to handle things so that you can rotate multiple objects and at the same time with more variables make it so they know where the tip of the gun is to shoot. I have one more efficient then this for my game right now... xD
Gee...thx a lot, Klaus (Is that pronounced "Clozz" or "Clouse"?)
Also, I liked ur old picture better.
Anyway, my system does work with multiple objects. Also, you could modify it to work from one object to another, and you could make it adjust an angular velocity variable instead of the angle.
I'm just saying what makes yours so much better than mine?
I am just saying that you're neat little trick is just a lower grade version of a proper trigonometry based rotation system for MCs. Sorry to bust your bubble but this is simple if not basic stuff in AS. It's pronounces Clouse, like Mouse, or Claus like Santa Claus I have no preference.
Well, if you're gonna put me down at least put it on my message board and not in my open forum. Still, good feedback (I whipped that equation up in 15 minutes).
And I think [Clouse]house sounds cooler than [Clause]house.
I thinkk Clousehouse sounds better too. Someone actually spelled it MouseHouse once. And I didn't mean to put you down it's just common for me so I guess I overeacted! My apologies. Still good that you figured this out by yourself and not from an online tut, better than alot of people can do!
But we are waaaaaaaaaaaaaaaaaaaaaaaaaay off-topic (though I gues this isn't really a topic). Well, if mine can't do the things yours can, then how could I improve it?
Well I you need to do to improve it enough for what most people need(unlike me, I need some complicated things) is a variable that you put your final degree that it will be going to on. Like MyDegrees or something. That was you can move multiple items at the same time and if it shoots you can shoot something and already know which angle it must be attached at?
Well see what should be happenning is you need to find the amount of degrees between you're MC and the mouse. this amount of degrees should be kept in a variable which I call MyDregrees. So then all you need to do is something._rotation += Mydegrees. So then you can start rotating many items off of just one equation and also you just use my degrees to know where the gun is pointing so that you can attachMovie something at the tip of it.
I think i see what you are getting at. For my game, I need it to face the mouse so when I click it shoots something (so original). I think that my thing will work in that situation. May I ask what advanced thing you need your MyDegrees for, or would it be a spoiler of your game.
Well for some of my work I need it not only because something is come from the spot but to it. So I will need arc angles and parabolas and huge equations to get an arc going on towards the spot that is moving to my mouse and such. But it's all just for my own gain not a game itself. It's useful to have these things lying around for a game whenever you need it!