Android Question Setting Gravity on Falling Sand Game.

WebbyBoy

Member
Licensed User
Longtime User
Hi,

I'm trying out a few things on the Falling Sand Game @ the below link & cannot figure out how to change the Gravity. @Erel had updated the code with a switch to change the gravity, but I would like to change the gravity according to the output from the TYPE_ACCELEROMETER phone sensor so it will move the objects. Is there a way of changing the gravity incrementally?

I've already got the readings from the accelerometer to get the right direction details, I just need the gravity to change accordingly & it is baffling me.

Any help at all will be well received. Cheers.


Gravity:
Sub btnGravity_Click
    Dim btn As B4XView = Sender
    GravityDown = Not(GravityDown)
    If GravityDown Then
        btn.SetRotationAnimated(500, 0)
    Else
        btn.SetRotationAnimated(500, 180)
    End If
    ToastMessageShow("RSL: " & RowsState.Length,False)
   
    AllDirty
End Sub

AllDirty:
Private Sub AllDirty
    For i = 0 To RowsState.Length - 1
        RowsState(i) = 1
    Next
End Sub
 
Top