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.
when gf clicked forever if <touching [player v]?> change x by ([x velocity v] of [player v])The only problem with this is that you will also pull it. This may fix that:
when gf clicked forever if <touching [player v]?> if <(x position) < ([x position v] of [player v])> //if the player is on my right if <([x velocity v] of [player v]) < [0]> //if the player is moving to the right change x by ([x velocity v] of [player v]) //change my x by the speed of the player end else //if the player is on my left if <([x velocity v] of [player v]) > [0]> //if the player is moving to the left change x by ([x velocity v] of [player v]) endJust ask if you don't know what x velocity is.
Last edited by Splodgey (2012-03-13 09:21:11)
Offline
Splodgey wrote:
OK, maybe not. It's rather simple.
when gf clicked forever if <touching [player v]?> change x by ([x velocity v] of [player v])The only problem with this is that you will also pull it. This may fix that:when gf clicked forever if <touching [player v]?> if <(x position) < ([x position v] of [player v])> //if the player is on my right if <([x velocity v] of [player v]) < [0]> //if the player is moving to the right change x by ([x velocity v] of [player v]) //change my x by the speed of the player end else //if the player is on my left if <([x velocity v] of [player v]) > [0]> //if the player is moving to the left change x by ([x velocity v] of [player v]) endJust 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
Money_B_Freaky_D wrote:
Splodgey wrote:
OK, maybe not. It's rather simple.
when gf clicked forever if <touching [player v]?> change x by ([x velocity v] of [player v])The only problem with this is that you will also pull it. This may fix that:when gf clicked forever if <touching [player v]?> if <(x position) < ([x position v] of [player v])> //if the player is on my right if <([x velocity v] of [player v]) < [0]> //if the player is moving to the right change x by ([x velocity v] of [player v]) //change my x by the speed of the player end else //if the player is on my left if <([x velocity v] of [player v]) > [0]> //if the player is moving to the left change x by ([x velocity v] of [player v]) endJust 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 v] of [player v])It can be found in the "sensing" tab. Above loudness and below timer.
(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:
when gf clicked forever if <touching [player v]?> change x by ([x velocity v] of [player v])The only problem with this is that you will also pull it. This may fix that:when gf clicked forever if <touching [player v]?> if <(x position) < ([x position v] of [player v])> //if the player is on my right if <([x velocity v] of [player v]) < [0]> //if the player is moving to the right change x by ([x velocity v] of [player v]) //change my x by the speed of the player end else //if the player is on my left if <([x velocity v] of [player v]) > [0]> //if the player is moving to the left change x by ([x velocity v] of [player v]) endJust 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
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