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
Ah, a little complex.
Let me have a look...
Offline
OK, maybe not. It's rather simple.
The only problem with this is that you will also pull it. This may fix that:whenclicked
foreveriftouchingplayer ▼?change x byx velocity ▼ofplayer ▼
Just ask if you don't know what x velocity is.whenclicked
foreveriftouchingplayer ▼?ifx position<x position ▼ofplayer ▼if the player is on my rightif<x velocity ▼ofplayer ▼0if the player is moving to the rightchange x byx velocity ▼ofplayer ▼change my x by the speed of the playerelseif the player is on my leftif>x velocity ▼ofplayer ▼0if the player is moving to the leftchange x byx velocity ▼ofplayer ▼
Last edited by Splodgey (2012-03-13 09:21:11)
Offline
Splodgey wrote:
OK, maybe not. It's rather simple.
The only problem with this is that you will also pull it. This may fix that:whenclicked
foreveriftouchingplayer ▼?change x byx velocity ▼ofplayer ▼Just ask if you don't know what x velocity is.whenclicked
foreveriftouchingplayer ▼?ifx position<x position ▼ofplayer ▼if the player is on my rightif<x velocity ▼ofplayer ▼0if the player is moving to the rightchange x byx velocity ▼ofplayer ▼change my x by the speed of the playerelseif the player is on my leftif>x velocity ▼ofplayer ▼0if the player is moving to the leftchange x byx velocity ▼ofplayer ▼
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
Money_B_Freaky_D wrote:
Splodgey wrote:
OK, maybe not. It's rather simple.
The only problem with this is that you will also pull it. This may fix that:whenclicked
foreveriftouchingplayer ▼?change x byx velocity ▼ofplayer ▼Just ask if you don't know what x velocity is.whenclicked
foreveriftouchingplayer ▼?ifx position<x position ▼ofplayer ▼if the player is on my rightif<x velocity ▼ofplayer ▼0if the player is moving to the rightchange x byx velocity ▼ofplayer ▼change my x by the speed of the playerelseif the player is on my leftif>x velocity ▼ofplayer ▼0if the player is moving to the leftchange x byx velocity ▼ofplayer ▼
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.
It can be found in the "sensing" tab. Above loudness and below timer.x velocity ▼ofplayer ▼
x velocity
Last edited by Splodgey (2012-03-13 09:38:41)
Offline
Okay, that cleared things up, and I've got it working now. Thanks, this helped a lot.
Offline
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
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:
The only problem with this is that you will also pull it. This may fix that:whenclicked
foreveriftouchingplayer ▼?change x byx velocity ▼ofplayer ▼Just ask if you don't know what x velocity is.whenclicked
foreveriftouchingplayer ▼?ifx position<x position ▼ofplayer ▼if the player is on my rightif<x velocity ▼ofplayer ▼0if the player is moving to the rightchange x byx velocity ▼ofplayer ▼change my x by the speed of the playerelseif the player is on my leftif>x velocity ▼ofplayer ▼0if the player is moving to the leftchange x byx velocity ▼ofplayer ▼
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
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