I have been looking at the Box2D_Tumbler example provided with libGDX. I want the rotation to start when the screen is touched. in the LG_Create sub there is the following
and I have the sub
When the screen is touched, the rotatebod is set true and the code below in LG_Update is used to enable the motor
however, nothing happens as the body remains stationary. Can anyone suggest what I'm missing? I know the LG_TouchDown is firing correctly because of the logs. Thanks
B4X:
rotatebod=False
'Dim jd As lgBox2DRevoluteJointDef - This has been moved the Globals so I can enable the motor in the LG_Update sub
jd.bodyA = groundBody
jd.bodyB = body
jd.localAnchorA.set(0, 10)
jd.localAnchorB.set(0, 0)
jd.referenceAngle = 0
jd.motorSpeed = 0 '0.5 * cPI
jd.maxMotorTorque = 1e8
'jd.enableMotor = True if this is uncommented then the body rotates immediately
jd.enableMotor=False
World.CreateJoint(jd)
and I have the sub
B4X:
Sub LG_TouchDown(ScreenX As Int, ScreenY As Int, Pointer As Int) As Boolean
Log(ScreenX)
rotatebod=True
Log(rotatebod)
End Sub
When the screen is touched, the rotatebod is set true and the code below in LG_Update is used to enable the motor
B4X:
Log(rotatebod)
If rotatebod=True Then
jd.motorSpeed=0.5 * cPI
Else
jd.motorSpeed=0
End If