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

#1 2010-09-20 14:57:42

stickfiregames
Scratcher
Registered: 2010-08-14
Posts: 3

rotating a sprite around another sprite

I need a script to let me rotate a sprite, not around its center but around the center of a different sprite. does anyone know how to do this?

Offline

 

#2 2010-09-20 19:06:24

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: rotating a sprite around another sprite

Well there's several ways you could do this. You could change the costume center in the paint editor so it's offset the right distance from the sprite, then just have it turn like normal. Or, if the sprite is going to be doing more than just that, you could use trigonometry.


http://www.blocks.scratchr.org/API.php?action=random&return=image&link1=http://i.imgur.com/OZn2RD3.png&link2=http://i.imgur.com/duzaGTB.png&link3=http://i.imgur.com/CrDGvvZ.png&link4=http://i.imgur.com/POEpQyZ.png&link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#3 2010-09-20 20:19:31

coolstuff
Community Moderator
Registered: 2008-03-06
Posts: 1000+

Re: rotating a sprite around another sprite

Like Harakou said, it's possible to achieve this by changing the sprite's costume center. However, it can be quite difficult to get that just right and it's a pain to work with. Trigonometry, however difficult it may be to understand, should do the trick. If you'd like, I can make a project demonstrating how to do this for you.

Offline

 

#4 2010-09-21 13:01:13

stickfiregames
Scratcher
Registered: 2010-08-14
Posts: 3

Re: rotating a sprite around another sprite

What I was looking for was one that would rotate around the second sprite regardless of where the second sprite was. I don't think changing the center would work for that. If trigonometry would work then please could you make the demonstration project.

BTW, its for a racing game where the background scrolls and rotates

Offline

 

#5 2010-09-21 15:24:46

colorfusion
Scratcher
Registered: 2009-10-03
Posts: 500+

Re: rotating a sprite around another sprite

stickfiregames wrote:

What I was looking for was one that would rotate around the second sprite regardless of where the second sprite was. I don't think changing the center would work for that. If trigonometry would work then please could you make the demonstration project.

BTW, its for a racing game where the background scrolls and rotates

Make it point to the right sprite, turn 90 degrees then move ___ steps.

Offline

 

#6 2010-09-21 22:32:05

TheBajeebas
Scratcher
Registered: 2010-04-26
Posts: 1000+

Re: rotating a sprite around another sprite

You can use this if you want:

http://scratch.mit.edu/projects/TheBajeebas/1311476


http://i.imgur.com/jOkeD.jpg

Offline

 

#7 2010-10-08 06:55:06

Hardmath123
Scratcher
Registered: 2010-02-19
Posts: 1000+

Re: rotating a sprite around another sprite

Actually, you don't need trigonometry (I think you got an answer by now, but still). Just make (point towards sprite) (go to sprite) (rotate 180* clockwise) (move how far you want to be away from sprite) (rotate 90* clockwise) (move 10 steps).


Hardmaths-MacBook-Pro:~ Hardmath$ sudo make $(whoami) a sandwich

Offline

 

Board footer