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

#1 2008-10-30 22:50:10

techstars
Scratcher
Registered: 2008-10-07
Posts: 8

i have a qwestion

I need no make a sprite shoot when it picks up a gun.

Offline

 

#2 2008-10-31 04:18:26

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

Re: i have a qwestion

I'd probably use a variable.  for example "hasgun"

On green flag, set "hasgun" to 0

Then, at the beginning of your shooting script, add
"If hasgun=1" as a condition that runs the shooting, as well as the key-press or mouseclick.

Then, on the gun sprite

If touching sprite "player"
   hide
   set hasgun to 1


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

 

#3 2008-10-31 07:14:11

Goldfish01
Scratcher
Registered: 2008-05-08
Posts: 36

Re: i have a qwestion

It would look like

<when green flag clicked>
<set{ hasgun }to( 0
<forever>
<if><touching[ gun
<set{ hasgun }to( 1
<end>
<end>


Improvement is dissasembling something and not putting it back together properly.

Offline

 

#4 2008-10-31 20:29:23

techstars
Scratcher
Registered: 2008-10-07
Posts: 8

Re: i have a qwestion

i mean the gun is part of the sprite

Offline

 

#5 2008-10-31 21:03:51

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

Re: i have a qwestion

<when green flag clicked>
<set{ hasgun }to( 0
<forever>
<if><touching[ gun
<set{ hasgun }to( 1
<end>
<end>

<when green flag clicked>
<forever>
<if><( <{ hasgun }> <=> 1 )>
<switch to costume[ gun
<else>
<switch to costume[ nogun
<end>
<end>

Offline

 

#6 2008-10-31 21:23:08

bhz
Scratcher
Registered: 2008-07-06
Posts: 100+

Re: i have a qwestion

<when green flag clicked>
<set{ hasgun }to( 0
<forever>
<if><touching[ gun
<set{ hasgun }to( 1 )
<else>
<set{ hasgun }to( 0 )
<end>
<end>

<when green flag clicked>
<forever>
<if><( <{ hasgun }> <=> 1 )>
<switch to costume[ gun ]
<else>
<switch to costume[ nogun ]
<end>
<end>

correction

Offline

 

Board footer