Hello. I am writing to ask a question because I encountered a problem while coding a ladybug tracking game using App Inventor.
The insects move based on the phone's angle using the orientation sensor, but they keep moving outside the canvas area. I am a
sking if there is a way to fix this.
Please switch the language to English, then download this block images.
Your issue is not with the orientation sensor — it’s because you’re not constraining the sprite position inside the canvas.
Right now you only handle this:
when ladybug.EdgeReached → move to edge + speed = 0
That just reacts after it goes out of bounds, which is why it keeps slipping outside.
Proper fix: Clamp position inside canvas
In your UpdateLadybug (and similar for other sprites), you need to limit X and Y manually.
Add this logic after updating position:
set ladybug.X to max(0, min(ladybug.X, Canvas.Width - ladybug.Width))
set ladybug.Y to max(0, min(ladybug.Y, Canvas.Height - ladybug.Height))