Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Sprite picking up a sprite
- CGuzman1
-
New Scratcher
5 posts
Sprite picking up a sprite
How do I make a sprite pick up another sprite. For example, my sprite is supposed to pick up a block by pressing the up key. How can i get it to do this? Please and thank you.
- upelly
-
Scratcher
16 posts
Sprite picking up a sprite
the holder script
when [up arrow v] key pressed
broadcast [pickup v]
when [down arrow arrow v] key pressed
set [whatever v] to [0]
the object to be picked up
when I receive [pickup v]
repeat until <[1] = (whatever)>
go to x: () y: ()
end
enter into the empty spaces the block of x and y positions of the other sprite
- upelly
-
Scratcher
16 posts
Sprite picking up a sprite
oops I meant what I have made it now
the holder scriptwhen [up arrow v] key pressed
broadcast [pickup v]
when [down arrow arrow v] key pressed
set [whatever v] to [1]
the object to be picked up
when I receive [pickup v]
repeat until <[1] = (whatever)>
go to x: () y: ()
end
enter into the empty spaces the block of x and y positions of the other sprite[/quote]
Last edited by upelly (Nov. 21, 2013 14:54:11)
- Poosheku
-
Scratcher
72 posts
Sprite picking up a sprite
Hmmm…sounds pretty tricky. Try this: Make your character's arm a seperate Sprite, and program:
~Under the arm Sprite:

~Under the arm Sprite:
foreverAnd after that all you need to do is make your character's movement conditional:It can't move if
if <(up) = [0] >then
go to [full character v]
when [up arrow v] key pressed
set (up) to [1]
movement stuff
set (up) to [0]
< (up) = [1] >Hope this helps!

Last edited by Poosheku (Nov. 21, 2013 16:09:10)
- picopaper
-
Scratcher
500+ posts
Sprite picking up a sprite
First, I would make a pickup costume in my sprite. Then, I'd program it like so:
Next, I'd program into my block sprite;
Hope this helps!
when green flag clicked
forever
if <key [up arrow v] pressed?> then
switch costume to [pickup v]
set [pickup v] to [1]
end
end
Next, I'd program into my block sprite;
when green flag clicked
forever
if <[pickup] = [1]> then
change y by (you'd have to experiment with this...)
end
end
Hope this helps!

- LinaLJ
-
New Scratcher
1 post
Sprite picking up a sprite
Hey guys, how can i make the girl pick up basketball and run with it? quick answers plz
- Invisible_Factory
-
Scratcher
500+ posts
Sprite picking up a sprite
when green flag clickedIn the block sprite…
forever
if <key [up arrow v] pressed?> then
switch costume to [pickup v]
broadcast [pickup v]
end
end
when I receive [pickup v]In this case the pickup costume is the sprite with the block and you hide the block.
hide
Last edited by Invisible_Factory (Jan. 2, 2016 17:58:42)
- Discussion Forums
- » Help with Scripts
-
» Sprite picking up a sprite