This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-03-02 12:41:51

Smozzick
Scratcher
Registered: 2011-10-23
Posts: 100+

Point in direction of x-y co-ordinate?

Hi, I'm trying to work out how to calculate the direction to a point on the screen. Anyone know how to do this? I'm guessing it's something using sin but I have no idea what :s

Note: Trying to avoid using a new sprite and having it go somewhere to be pointed at

Last edited by Smozzick (2012-03-02 12:42:16)


http://i50.tinypic.com/ded8m.png

Offline

 

#2 2012-03-02 16:58:51

bobbybee
Scratcher
Registered: 2009-10-18
Posts: 1000+

Re: Point in direction of x-y co-ordinate?

atan2...Wikipedia will be your friend here.


I support the Free Software Foundation. Protect our digital rights!

Offline

 

#3 2012-03-02 17:06:12

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Point in direction of x-y co-ordinate?

Yes...but it requires some trig...actually, I have a tutorial on this.


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

#4 2012-03-02 17:22:57

RedRocker227
Scratcher
Registered: 2011-10-26
Posts: 1000+

Re: Point in direction of x-y co-ordinate?


Why

Offline

 

#5 2012-03-03 07:17:36

Smozzick
Scratcher
Registered: 2011-10-23
Posts: 100+

Re: Point in direction of x-y co-ordinate?

Thanks for all of these; they were very useful and I might go over that trig tutorial sometime to check if there's anything else I don't know from it. I'm already fine with pendulum motions, oscillation and such so this was the last main obvious thing.

Pity the codes so long <.<


http://i50.tinypic.com/ded8m.png

Offline

 

#6 2012-03-03 07:48:11

Greenatic
Scratcher
Registered: 2009-05-03
Posts: 1000+

Re: Point in direction of x-y co-ordinate?

Smozzick wrote:

Thanks for all of these; they were very useful and I might go over that trig tutorial sometime to check if there's anything else I don't know from it. I'm already fine with pendulum motions, oscillation and such so this was the last main obvious thing.

Pity the codes so long <.<

There's actually an obsolete block for this--I know it will work downloaded, maybe in Java, but not in Flash.

Last edited by Greenatic (2012-03-03 18:32:43)

Offline

 

#7 2012-03-03 18:12:46

Smozzick
Scratcher
Registered: 2011-10-23
Posts: 100+

Re: Point in direction of x-y co-ordinate?

Greenatic wrote:

There's a actually an obsolete block for this--I know it will work downloaded, maybe in Java, but not in Flash.

Huh, that's cool; though I try to avoid using those to stop people form having to download the project.


http://i50.tinypic.com/ded8m.png

Offline

 

#8 2012-03-04 17:09:01

TheBlueRocky
Scratcher
Registered: 2010-07-08
Posts: 500+

Re: Point in direction of x-y co-ordinate?

Easiest solution:

Make an invisible sprite at those coordinates. Make the shown sprite face the invisible one! Voila.

Offline

 

Board footer