How to move a sprite with shaking

i’d like moving a sprite on the canvas with the accelerometer.
in theory, the sprite moves when i shake the device.
how would i can do?

use the Shaking event of the AccelerometerSensor component and move your sprite there

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select “Download Blocks as Image”. You might want to use an image editor to crop etc. if required. Then post it here in the community.


here is the blocks


you should use the same x and y coordinates as previously for the Point In Diretion method…
to do this, you might want to use a local variable for x and another local variable for y to get a random x any y position and assign these local ariables to both methods


like this?

Finally, I solved the problem.
here is the algorithm
projet 1

1 Like

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