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

#1 2012-03-13 08:46:07

Money_B_Freaky_D
New Scratcher
Registered: 2012-03-05
Posts: 3

How to make a sprite push another sprite

I'm making a game and need one of my sprites to push a block so that they can jump up onto it and continue to the next level. How can I make the block move with the sprite and stop?

Offline

 

#2 2012-03-13 09:00:25

Splodgey
Scratcher
Registered: 2011-04-26
Posts: 500+

Re: How to make a sprite push another sprite

Ah, a little complex.
Let me have a look...

Offline

 

#3 2012-03-13 09:05:14

Splodgey
Scratcher
Registered: 2011-04-26
Posts: 500+

Re: How to make a sprite push another sprite

OK, maybe not. It's rather simple.

when clicked
forever
if
touching
player
?
change x by
x velocity
of
player

The only problem with this is that you will also pull it. This may fix that:
when clicked
forever
if
touching
player
?
if
x position
<
x position
of
player
if the player is on my right
if
x velocity
of
player
<
0
if the player is moving to the right
change x by
x velocity
of
player
change my x by the speed of the player
else
if the player is on my left
if
x velocity
of
player
>
0
if the player is moving to the left
change x by
x velocity
of
player

Just ask if you don't know what x velocity is.
You would need to do the same with y velocity.
If you did not understand see this project here.

Last edited by Splodgey (2012-03-13 09:21:11)

Offline

 

#4 2012-03-13 09:31:46

Money_B_Freaky_D
New Scratcher
Registered: 2012-03-05
Posts: 3

Re: How to make a sprite push another sprite

Splodgey wrote:

OK, maybe not. It's rather simple.

when clicked
forever
if
touching
player
?
change x by
x velocity
of
player

The only problem with this is that you will also pull it. This may fix that:
when clicked
forever
if
touching
player
?
if
x position
<
x position
of
player
if the player is on my right
if
x velocity
of
player
<
0
if the player is moving to the right
change x by
x velocity
of
player
change my x by the speed of the player
else
if the player is on my left
if
x velocity
of
player
>
0
if the player is moving to the left
change x by
x velocity
of
player

Just ask if you don't know what x velocity is.
You would need to do the same with y velocity.
If you did not understand see this project here.

I have x velocity programmed into scratch as a variable as well as y velocity, but I don't see how to change x by "x velocity of player", the variable doesn't move into that spot. I've tried x position instead, but it doesn't seem to be working.

Offline

 

#5 2012-03-13 09:38:30

Splodgey
Scratcher
Registered: 2011-04-26
Posts: 500+

Re: How to make a sprite push another sprite

Money_B_Freaky_D wrote:

Splodgey wrote:

OK, maybe not. It's rather simple.

when clicked
forever
if
touching
player
?
change x by
x velocity
of
player

The only problem with this is that you will also pull it. This may fix that:
when clicked
forever
if
touching
player
?
if
x position
<
x position
of
player
if the player is on my right
if
x velocity
of
player
<
0
if the player is moving to the right
change x by
x velocity
of
player
change my x by the speed of the player
else
if the player is on my left
if
x velocity
of
player
>
0
if the player is moving to the left
change x by
x velocity
of
player

Just ask if you don't know what x velocity is.
You would need to do the same with y velocity.
If you did not understand see this project here.

I have x velocity programmed into scratch as a variable as well as y velocity, but I don't see how to change x by "x velocity of player", the variable doesn't move into that spot. I've tried x position instead, but it doesn't seem to be working.

x velocity
of
player

It can be found in the "sensing" tab. Above loudness and below timer.
If your player's velocity is a "for all sprites" variable, then use this instead;
x velocity

Last edited by Splodgey (2012-03-13 09:38:41)

Offline

 

#6 2012-03-13 09:53:15

Money_B_Freaky_D
New Scratcher
Registered: 2012-03-05
Posts: 3

Re: How to make a sprite push another sprite

Okay, that cleared things up, and I've got it working now. Thanks, this helped a lot.

Offline

 

#7 2012-03-14 07:43:26

cbhattarai
New Scratcher
Registered: 2012-02-11
Posts: 7

Re: How to make a sprite push another sprite

Money_B_Freaky_D wrote:

Okay, that cleared things up, and I've got it working now. Thanks, this helped a lot.

Can you please PM me the Script...

Offline

 

#8 2012-03-14 08:23:50

Splodgey
Scratcher
Registered: 2011-04-26
Posts: 500+

Re: How to make a sprite push another sprite

cbhattarai wrote:

Money_B_Freaky_D wrote:

Okay, that cleared things up, and I've got it working now. Thanks, this helped a lot.

Can you please PM me the Script...

Here:

Splodgey wrote:

when clicked
forever
if
touching
player
?
change x by
x velocity
of
player

The only problem with this is that you will also pull it. This may fix that:
when clicked
forever
if
touching
player
?
if
x position
<
x position
of
player
if the player is on my right
if
x velocity
of
player
<
0
if the player is moving to the right
change x by
x velocity
of
player
change my x by the speed of the player
else
if the player is on my left
if
x velocity
of
player
>
0
if the player is moving to the left
change x by
x velocity
of
player

Just ask if you don't know what x velocity is.
You would need to do the same with y velocity.
If you did not understand see this project here.

Why didn't you just scroll up?

Offline

 

#9 2012-03-14 08:29:59

scimonster
Community Moderator
Registered: 2010-06-13
Posts: 1000+

Re: How to make a sprite push another sprite

cbhattarai wrote:

Money_B_Freaky_D wrote:

Okay, that cleared things up, and I've got it working now. Thanks, this helped a lot.

Can you please PM me the Script...

There is no PMing on Scratch.
Try using a script shown above, or get it from his project when it gets uploaded.

Offline

 

Board footer