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

#1 2013-04-29 20:09:04

LucarioMage
New Scratcher
Registered: 2013-04-05
Posts: 4

follow a rotating object(hinge-arm)

So, I have a stick figure, and I want his arms to have a joint in the middle.  so far, when they are 90 degrees, they look like a straight line and the bottom section can rotate no problem, but if I were to rotate the top portion, it would look like this:

\   <-Top
  \
| <--Bottom
|

How can I get it to do this at any angle, like this?
           | \    Top
body    |  \
           |  /   Bottom
           | /

Offline

 

#2 2013-04-29 21:03:49

ErnieParke
Scratcher
Registered: 2010-12-03
Posts: 1000+

Re: follow a rotating object(hinge-arm)

Well, that would require some trigonometry, and I also need to know one more thing. Where is the center on your top arm's sprite? Is that the same on the bottom arm's sprite, or is it in a different location? Once I know that, I can tell you easily.  wink

With regards,

ErnieParke


http://i46.tinypic.com/35ismmc.png

Offline

 

#3 2013-04-30 17:51:11

LucarioMage
New Scratcher
Registered: 2013-04-05
Posts: 4

Re: follow a rotating object(hinge-arm)

Both of them have the center of rotation at the very top.  As for the trigonometry, that would be in another 3 or 4 years for me, so, no wonder I didn't know what to do.  Thank you!

Offline

 

#4 2013-04-30 20:00:36

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

Re: follow a rotating object(hinge-arm)

LucarioMage wrote:

Both of them have the center of rotation at the very top.  As for the trigonometry, that would be in another 3 or 4 years for me, so, no wonder I didn't know what to do.  Thank you!

There is actually a way to do it without using trigonometry.  Have the lower segment set it's position to that of the upper one.  Then, using the upper arm's direction and the move block, have it move to the position needed.  The move block accomplishes the same thing trig will without you having to know what it's doing.


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

Offline

 

#5 2013-05-01 17:39:28

LucarioMage
New Scratcher
Registered: 2013-04-05
Posts: 4

Re: follow a rotating object(hinge-arm)

I mean, each piece has the Center of rotation at the top of each of themselves like an arm.

AtomicBawm3, but I am not sure if scratch 1.4 is fast enough, so it might flicker back and forth.  I'll try it now.

Offline

 

#6 2013-05-01 18:03:06

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

Re: follow a rotating object(hinge-arm)

LucarioMage wrote:

I mean, each piece has the Center of rotation at the top of each of themselves like an arm.

AtomicBawm3, but I am not sure if scratch 1.4 is fast enough, so it might flicker back and forth.  I'll try it now.

It shouldn't flicker when it's in a buffered stage (online or full screen) as long as they happen in the same loop of the script (as in they sit right next to each other in the script like so):

set [my direction v] to (direction)
go to [upper arm v]
point in direction ([direction v] of [upper arm v])
move (20) steps
point in direction (my direction)
where 20 is the length of the arm in pixels


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

Offline

 

Board footer