This example shows two things:
1. How to use a MotorJoint to make a body follow a path of points.
The difficult part was to make the body turn through the shortest direction.
A useful FindAngleToTarget sub is included in the example.
2. How to use the new async drawing features added in BitmapCreator v4.5. These features are very important as they allow us to make drawings directly to X2.MainBC.
X2.MainBC is the BitmapCreator that all the bodies are drawn to (by default).
Start with this tutorial: https://www.b4x.com/android/forum/posts/622812/
It looks like this:
gs.DrawingTasks.Add(X2.MainBC.AsyncDrawCircle(v.X, v.Y, 5, BrushBackwards, True, 0))
Remember that X2.MainBC is cleared every cycle so you need to draw everything every tick.
Drawing paths asynchronously requires careful handling. You shouldn't modify the path object while it is being drawn.
You should use a "copy on write" implementation:
PathMainBCBackwards = PathMainBCBackwards.Clone PathMainBCBackwards.LineTo(v.X, v.Y)
The example is included in the examples pack.