How can I make a sprite move only when I hold down a button and stop moving when I Release

how can I make a sprite move only when I hold down a button and stop moving when I Release

This post was flagged by the community and is temporarily hidden.

This post was flagged by the community and is temporarily hidden.

So basically I have a platformer we're a Sprite moves around and Dodge's obstacles and so far I have it so if you click a button he teleports to the left or right or up or down and what I need is so that you don't have to like spam the right button or something cuz it only moves him a certain amount each time you press the button so in order to move them like across the screen you need to spam click the right button so what I need Is to be able to like hold it down and have that command repeat itself until I release it and then when I release the button He stops moving Can anybody help me?

This post was flagged by the community and is temporarily hidden.

Use the button touchdown and touchup events to do this

1 Like

k. me try.

Is there such a thing as a "repeat command block"

For an interactive app, use a Clock Timer.

1 Like

Screenshot 2025-01-25 7.39.59 PM
this is what I have and "BOB" won't stop moving to the right, HELP!

Is there anything else moving Bob to the right?

Other Clock Timers?

Bob's Speed and Heading?

Are you missing a Canvas event block to stop sprites when they reach edges?

1 Like

Screenshot 2025-01-25 10.30.28 PM
nope it was originally this but its really choppy, and requires you to hit a button really quickly to move him fast enough to jump over obstacles

the problem is that for the code earlier when I held the button "BOB" started to move, witch is good. But when I took my finger off the button he kept moving wen he needs to be stopping.
Screenshot 2025-01-25 7.39.59 PM

It's not clear from the blocks you posted why the touch up event doesn't fire when you take your finger off the button, stopping the clock.

Maybe if you export and post your aia it might hold some information for whoever will be here in the next 12 hours.
(I'm off)

1 Like

Try this example:

touchspritemove.aia (9.9 KB)

1 Like

k. it just started working, I think my computer was bugging or something. thank you for the help :slight_smile:


Ok, so I have this. And the code to make him move to the right is working but, the code for the left movement moves him to the right when it, as far as I know, should make him go to the left. Do you know what is happening? If so please tell me. Thank you.

Yes, you set the right clock running when you press the left button :slight_smile:

1 Like

thank you I am apparently stooped

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.