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

#1 2012-07-17 22:58:44

Kajunkat
Scratcher
Registered: 2012-06-30
Posts: 37

Help!

I want to make a button that selects a random gender for a sprite. How can I do this? Please respond asap!!!!

Offline

 

#2 2012-07-17 23:06:04

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

Re: Help!

Kajunkat wrote:

I want to make a button that selects a random gender for a sprite. How can I do this? Please respond asap!!!!

There are several ways...probably the easiest would be this:

when Random Gender clicked
if <(pick random (0) to (1)) = (0)>
  set [gender v] to [male]
else
  set [gender v] to [female]
end
Hope that helps!


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

Offline

 

#3 2012-07-18 22:52:09

Kajunkat
Scratcher
Registered: 2012-06-30
Posts: 37

Re: Help!

It has to be a variable? I used it as a broadcast?

Offline

 

#4 2012-07-19 10:38:26

Prestige
Scratcher
Registered: 2008-12-15
Posts: 100+

Re: Help!

A variable is the easiest solution, thats why AB3 said there were many possible ways. If you wanted to include a broadcast, you could do this:

when [Random Gender v] clicked
if <(pick random (0) to (1)) = (0)>
  broadcast [male v]
else
  broadcast [female v]
end

Last edited by Prestige (2012-07-19 10:38:54)


"Don't insult someone until you've walked a mile in their shoes. That way, if they don't like what you have to say, you'll be a mile away and still have their shoes  smile  "

Offline

 

Board footer