Is there is an equivalent to the angle(x1,y1,x2,y2) expression built into the sdk? Trivial to do manually I guess, but if there's an internal command, I'd rather use it.
https://developer.mozilla.org/en-US/doc ... Math/atan2
its essentially just this function, but to make it work like angle(x1,y1,x2,y2) something like this should work:
Math.Atan2(x2-x1,y2-y1)/(2*Math.PI) (you can omit the math.pi thing if you want the angle in radians rather than degrees)
Develop games in your browser. Powerful, performant & highly capable.
Yes, you could trace that expression to get the cr.angle (might be this name).
QuaziGNRLnose
Thanks, that looks like it'll work fine. I'm just starting to learn javascript; I didn't know it had math functions like atan built in. Guess I have a bit to learn...
rexrainbow
I could do that...but I'd be worried that it might break later on. If it's not a documented part of the sdk, there's no guarantee on fixed syntax, right? Or, maybe I'm worrying too much.
The function is cr.angleTo(x1, y1, x2, y2) and it's in common_prelude.js. It's a helper function that is used throughout the runtime, so the likelihood of it breaking later on is near zero. There are also a lot of other functions in that file that can by useful.