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

#1 2013-04-11 12:15:55

twilightgem
New Scratcher
Registered: 2013-04-11
Posts: 1

Using Variables

What is the script required so when a certain Sprite is touching another Sprite, the Variable (for example Score) is changed by 1? On my game, when the Pirate Ship touches the gold coin, I want the variable - Score to increase by 1.

Thank you.

Offline

 

#2 2013-04-11 14:53:12

ProgrammingPro01
Scratcher
Registered: 2011-07-30
Posts: 1000+

Re: Using Variables

Sorry, this doesn't belong in this forum. A good place for a topic like this would be Help with Scripts. But anyway, onto your question:

(This would be in the Pirate Ship sprite)

when gf clicked
forever
if  < touching [Gold Coin v] ? >
 change [Score] by [1]
else
end
end

Last edited by ProgrammingPro01 (2013-04-12 14:56:27)


Bye 1.4!
http://www.reactiongifs.com/wp-content/uploads/2013/04/sobbing.gifhttp://25.media.tumblr.com/tumblr_mbfh6bIamQ1qky11ho1_500.png

Offline

 

#3 2013-04-12 13:42:49

cobraguy
Scratcher
Registered: 2009-11-18
Posts: 100+

Re: Using Variables

ProgrammingPro01 wrote:

Sorry, this doesn't belong in this forum. A good place for a topic like this would be Help with Scripts. But anyway, onto your question:

(This would be in the Pirate Ship sprite)

when gf clicked
forever
if  < touching [Gold Coin v] ?>
 change [Score] by [1]
else
end
end

Fixed. Even though it's just one block.


Fruit Fighter, when your food eats you.
http://i.imgur.com/8CR6Lnj.png?1

Offline

 

#4 2013-04-12 15:24:38

joshuaho
Scratcher
Registered: 2012-08-20
Posts: 100+

Re: Using Variables

twilightgem wrote:

What is the script required so when a certain Sprite is touching another Sprite, the Variable (for example Score) is changed by 1? On my game, when the Pirate Ship touches the gold coin, I want the variable - Score to increase by 1.

Thank you.

when gf clicked
show
forever
if<touching gold coin> 
change [score] by(1)
when gf clicked
forever
if <[score]= [5]>
broadcast [you win]

Last edited by joshuaho (2013-04-12 15:26:00)


Did you know that you can go to space and see Mars by clicking here?

Offline

 

#5 2013-04-12 21:23:10

cobraguy
Scratcher
Registered: 2009-11-18
Posts: 100+

Re: Using Variables

joshuaho wrote:

twilightgem wrote:

What is the script required so when a certain Sprite is touching another Sprite, the Variable (for example Score) is changed by 1? On my game, when the Pirate Ship touches the gold coin, I want the variable - Score to increase by 1.

Thank you.

when gf clicked
show
forever
if<touching gold coin> 
change [score] by(1)
when gf clicked
forever
if <[score]= [5]>
broadcast [you win]

when gf clicked
show
forever
if<touching [gold coin v]?> 
change [score] by(1)
when gf clicked
forever
if <(score)= [5]>
broadcast [you win v]
Fixed.


Fruit Fighter, when your food eats you.
http://i.imgur.com/8CR6Lnj.png?1

Offline

 

#6 2013-04-16 22:04:09

joshuaho
Scratcher
Registered: 2012-08-20
Posts: 100+

Re: Using Variables

cobraguy wrote:

joshuaho wrote:

twilightgem wrote:

What is the script required so when a certain Sprite is touching another Sprite, the Variable (for example Score) is changed by 1? On my game, when the Pirate Ship touches the gold coin, I want the variable - Score to increase by 1.

Thank you.

when gf clicked
show
forever
if<touching gold coin> 
change [score] by(1)
when gf clicked
forever
if <[score]= [5]>
broadcast [you win]

when gf clicked
show
forever
if<touching [gold coin v]?> 
change [score] by(1)
when gf clicked
forever
if <(score)= [5]>
broadcast [you win v]
Fixed.

Thank you, I am not that good in making scratchblocks.  smile


Did you know that you can go to space and see Mars by clicking here?

Offline

 

Board footer