Discuss Scratch

MaggotMush
Scratcher
4 posts

How do you make a sprite move with clicks?

I've kind of been thinking of making a game in which you move by clicking on the place that you want to go. But I have no clue how to do this. We have the “go to mouse-pointer” script, but that's all I can think of that could help me with this. I know moving with the arrow keys would be a lot easier to script, but I want to test click movement, does anyone know if this is possible, and how?
MaggotMush
Scratcher
4 posts

How do you make a sprite move with clicks?

I figured something out!

By making a whole new sprite for the background, you can add a message that tells the “player” where to move.

whenthisspriteclicked
broadcastmessage1
whenIreceivemessage1
glide1secstox:mousexy:mousey

edit : Now the only problem left is figuring out how to set a walking animation when in movement. I'll try troubleshooting, but if anyone has any solutions please hit me up.

Last edited by MaggotMush (Oct. 30, 2018 14:43:24)

deck26
Scratcher
1000+ posts

How do you make a sprite move with clicks?

There is a ‘when stage clicked’ hat block as well.
MaggotMush
Scratcher
4 posts

How do you make a sprite move with clicks?

deck26 wrote:

There is a ‘when stage clicked’ hat block as well.
Oh yeah! I forgot about that, thank you.
Stalpinth
Scratcher
47 posts

How do you make a sprite move with clicks?

TheRandomno
Scratcher
46 posts

How do you make a sprite move with clicks?

I made a project that moves at a roughly consistent speed and includes basic animation. If you had a sprite designed in overhead view you could change the rotation style to all-around.

It uses the workaround for the glide block which allows you to change costume every frame.
iFluxx
Scratcher
100+ posts

How do you make a sprite move with clicks?

If you want the sprite to always move when you click, regardless where you click, do
whenclickedforeverifmousedown?thenchangexby:changeyby:
Or you could use broadcasts
whenclickedforeverifmousedown?thenbroadcastmoveWhenIreceivemovechangexby:changeyby:

deck26
Scratcher
1000+ posts

How do you make a sprite move with clicks?

Mouse down isn't enough - holding the mouse down is not the same as clicking but the forever loop would only check the mouse down. If you want to use @iFluxx's method you're better waiting until mouse down and waiting until not mouse down in the forever loop instead of having the if block.

The second method (broadcast) is one to be careful of. If the receiver gets any longer it may not complete between one broadcast and the next when it will restart.
iFluxx
Scratcher
100+ posts

How do you make a sprite move with clicks?

deck26 wrote:

Mouse down isn't enough - holding the mouse down is not the same as clicking but the forever loop would only check the mouse down. If you want to use @iFluxx's method you're better waiting until mouse down and waiting until not mouse down in the forever loop instead of having the if block.

The second method (broadcast) is one to be careful of. If the receiver gets any longer it may not complete between one broadcast and the next when it will restart.
Oh yeah forgot that lol
waituntilnotmousedown?

Last edited by iFluxx (Nov. 1, 2018 18:21:12)

3DGamer5
Scratcher
69 posts

How do you make a sprite move with clicks?

here is my way, make 2 sprites (one is for the player, one is for the cursor)

Sprite 2:

whenclickedbroadcastmouse

whenIreceivemouserepeatuntilmousedown?gotomouse pointerbroadcastwalk

sprite 1:

whenIreceivewalkrepeatuntiltouchingsprite2?pointtowardssprite2move10stepsbroadcastmouse

and thats it.


BTW here is a template: https://scratch.mit.edu/projects/254200103

Last edited by 3DGamer5 (Nov. 1, 2018 20:38:56)

Puppy_4_Life
New Scratcher
1 post

How do you make a sprite move with clicks?

How do you make the background bigger. Meaning like in the minecraft 11v.3 by griffpatch made it possible for you to move around in the background and not have to touch something to change the background to another one. How do you do that?
PersRufaro
Scratcher
100+ posts

How do you make a sprite move with clicks?

Puppy_4_Life wrote:

How do you make the background bigger. Meaning like in the minecraft 11v.3 by griffpatch made it possible for you to move around in the background and not have to touch something to change the background to another one. How do you do that?
Please don't post on old topics, but rather start your own. Try to remember next time.
- People might not respond to your question.

Last edited by PersRufaro (Feb. 16, 2020 05:46:30)

cs4865242
New Scratcher
1 post

How do you make a sprite move with clicks?

YOURE GETTING HACJED'
]

Last edited by cs4865242 (Feb. 24, 2020 15:49:23)

Teku_841
Scratcher
8 posts

How do you make a sprite move with clicks?

i mean this isnt about when you click and it moves there just reguler moving


whenclickedsetrotationstyle left rightforeverifkey apressed?thenpointindirection-90move10stepsifkey dpressed?thenpointindirection90move10steps
Teku_841
Scratcher
8 posts

How do you make a sprite move with clicks?

sorry its

whenclickedsetrotationstyleLeft right foreverifkeyapressed?thenpointindirection-90move10stepsifkeydpressed?thenpointindirection90move10steps
Teku_841
Scratcher
8 posts

How do you make a sprite move with clicks?

oh my god ok the if inside of the key a its supposed to go under the other if



Powered by DjangoBB