No tilt action
O.k it says Orientation not supported, so what can I do?:BangHead:
Even thou I am a total noob I understand that my Tablet only supports (ACCELEROMETER) So I followed your guide (
http://www.b4x.com/forum/basic4andr...6647-orientation-accelerometer.html#post38780)
& change it from this.
'Class module
Sub Class_Globals
Private animator As SpriteAnimator
Private sensor As PhoneSensors
Private SIZE = 12%x As Float
Private mbd As BitmapData
Private JUMP_SPEED As Float = -4%y
Private bricks As List
Private gm As GameManager
End Sub
Public Sub Initialize (bd As BitmapData, vBricks As List, vGm As GameManager)
mbd = bd
gm = vGm
mbd.DestRect.Initialize(50%x, 85%y, 50%x + SIZE, 90%y + SIZE)
bricks = vBricks
animator.Initialize
Dim r As Rect
animator.SetFrames(bd, Array As Rect(r), Array As Bitmap(LoadBitmap(File.DirAssets, "smiley.gif")))
animator.width = SIZE
animator.height = SIZE
sensor.Initialize2(sensor.TYPE_ORIENTATION, 0)
animator.vy = JUMP_SPEED
End Sub
Private Sub Sensor_SensorChanged (Values() As Float)
animator.vx = -PerXToCurrent(Max(-30, Min(30, Values(2))) / 10)
End Sub
Public Sub Tick
animator.vy = animator.vy + 0.2%y
mbd.Rotate = mbd.Rotate + animator.vx / 1%x
animator.Tick(mbd)
If animator.vy > 0 Then 'check for collisions on the way bottom
For Each brck As Brick In bricks
If brck.bd.DestRect.Left < mbd.DestRect.CenterX AND brck.bd.DestRect.Right > mbd.DestRect.CenterX Then
If mbd.DestRect.Bottom < brck.bd.DestRect.Top AND mbd.DestRect.Bottom + animator.vy + 0.2%y > brck.bd.DestRect.Top Then
'adjust the speed so the smiley will touch the brick on the next tick.
animator.vy = brck.bd.DestRect.Top - mbd.DestRect.Bottom - 0.2%y
Else If mbd.DestRect.Bottom = brck.bd.DestRect.Top Then
animator.vy = JUMP_SPEED
gm.PlaySound(gm.BOUNCE_SOUND, 1)
If brck.disappearing Then
brck.Shrink
End If
Exit
End If
End If
Next
End If
If animator.vy < 0 AND mbd.DestRect.Top < 40%y Then
'scroll the background
gm.ScrollDown(-animator.vy / 1.5)
mbd.DestRect.Top = mbd.DestRect.Top - animator.vy / 2
mbd.DestRect.Bottom = mbd.DestRect.Bottom - animator.vy / 2
End If
'instead of ending the game we bounce the smiley
If mbd.DestRect.Bottom >= 100%y Then animator.vy = JUMP_SPEED
End Sub
Public Sub StartSensor
sensor.StartListening("Sensor")
End Sub
Public Sub StopSensor
sensor.StopListening
End Sub
To this
'Class module
Sub Class_Globals
Private animator As SpriteAnimator
Private Accelerometer As PhoneAccelerometer
Private SIZE = 12%x As Float
Private mbd As BitmapData
Private JUMP_SPEED As Float = -4%y
Private bricks As List
Private gm As GameManager
End Sub
Public Sub Initialize (bd As BitmapData, vBricks As List, vGm As GameManager)
mbd = bd
gm = vGm
mbd.DestRect.Initialize(50%x, 85%y, 50%x + SIZE, 90%y + SIZE)
bricks = vBricks
animator.Initialize
Dim r As Rect
animator.SetFrames(bd, Array As Rect(r), Array As Bitmap(LoadBitmap(File.DirAssets, "smiley.gif")))
animator.width = SIZE
animator.height = SIZE
Accelerometer.Initialize2(Accelerometer.TYPE_ACCELEROMETER, 0)
animator.vy = JUMP_SPEED
End Sub
Private Sub Accelerometer_AccelerometerChanged (Values() As Float)
animator.vx = -PerXToCurrent(Max(-30, Min(30, Values(2))) / 10)
End Sub
Public Sub Tick
animator.vy = animator.vy + 0.2%y
mbd.Rotate = mbd.Rotate + animator.vx / 1%x
animator.Tick(mbd)
If animator.vy > 0 Then 'check for collisions on the way bottom
For Each brck As Brick In bricks
If brck.bd.DestRect.Left < mbd.DestRect.CenterX AND brck.bd.DestRect.Right > mbd.DestRect.CenterX Then
If mbd.DestRect.Bottom < brck.bd.DestRect.Top AND mbd.DestRect.Bottom + animator.vy + 0.2%y > brck.bd.DestRect.Top Then
'adjust the speed so the smiley will touch the brick on the next tick.
animator.vy = brck.bd.DestRect.Top - mbd.DestRect.Bottom - 0.2%y
Else If mbd.DestRect.Bottom = brck.bd.DestRect.Top Then
animator.vy = JUMP_SPEED
gm.PlaySound(gm.BOUNCE_SOUND, 1)
If brck.disappearing Then
brck.Shrink
End If
Exit
End If
End If
Next
End If
If animator.vy < 0 AND mbd.DestRect.Top < 40%y Then
'scroll the background
gm.ScrollDown(-animator.vy / 1.5)
mbd.DestRect.Top = mbd.DestRect.Top - animator.vy / 2
mbd.DestRect.Bottom = mbd.DestRect.Bottom - animator.vy / 2
End If
'instead of ending the game we bounce the smiley
If mbd.DestRect.Bottom >= 100%y Then animator.vy = JUMP_SPEED
End Sub
Public Sub StartAccelerometer
Accelerometer.StartListening("Accelerometer")
End Sub
Public Sub StopAccelerometer
Accelerometer.StopListening
End Sub
But I am getting complie error:
Parsing code. 0.07
Compiling code. Error
Error compiling program.
Error description: Unknown member: initialize2
Occurred on line: 22
Accelerometer.Initialize2(Accelerometer.TYPE_ACCELEROMETER, 0)
Word: initialize2
I am reading as much as I can but would love to have some help thanks