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

#1 2007-08-05 10:04:17

Llamalover
Scratcher
Registered: 2007-05-18
Posts: 100+

How can I make a sprite turn when dragged?

How can I make a sprite turn when dragged?


Be nice, I'm an old lady  wink

Offline

 

#2 2007-08-05 18:29:01

kevin_karplus
Scratcher
Registered: 2007-04-27
Posts: 1000+

Re: How can I make a sprite turn when dragged?

What behavior, exactly, do you want?  If you can describe the behavior precisely, you are halfway to programming it.

Offline

 

#3 2007-08-06 05:35:43

Llamalover
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: How can I make a sprite turn when dragged?

I want there for eample to be a knob on a circle, when you drag that knob clockwise the circle turns, but not the oher way


Be nice, I'm an old lady  wink

Offline

 

#4 2007-08-06 05:43:08

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: How can I make a sprite turn when dragged?

Relatively straightforward, in fact.

You just need to make your circle, ensure teh centre of rotation is in the middle and the knob is at the "front) (90 degrees by default) and script something along the lines of
If <touching mousepointer> AND <mouse down> point towards <mousepointer>

The tricky thing is that inside the scratch program, it won't work properly because of the built-in ability to drag and drop sprites in the programming window.  So to test it you'll need to go to full screen mode.


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#5 2007-08-06 06:16:17

Mayhem
Scratcher
Registered: 2007-05-26
Posts: 1000+

Re: How can I make a sprite turn when dragged?

Ah - wait - you only want it to turn one way, eg clockwise?

Trickier... you'd need to compare the current direction with the mouse direction to see if the turn is valid...  still doable, though.

Last edited by Mayhem (2007-08-06 06:18:12)


Web-spinning Spider:  http://scratch.mit.edu/projects/Mayhem/18456
3D Dungeon Adventure:  http://scratch.mit.edu/projects/Mayhem/23570
Starfighter X: http://scratch.mit.edu/projects/Mayhem/21825
Wandering Knight: http://scratch.mit.edu/projects/Mayhem/28484

Offline

 

#6 2007-08-06 07:13:07

Llamalover
Scratcher
Registered: 2007-05-18
Posts: 100+

Re: How can I make a sprite turn when dragged?

Thanks so much for your help!


Be nice, I'm an old lady  wink

Offline

 

Board footer