Sub Process_Globals
Dim Accelerometer As PhoneAccelerometer
End Sub
Sub Globals
Dim can As Canvas
Dim srect As Rect
Dim drect As Rect
Dim bm As Bitmap
End Sub
Sub Activity_Create(FirstTime As Boolean)
can.Initialize(Activity)
bm.Initialize(File.DirAssets,"PANO.jpg")
Dim l As Int = (bm.Width/2)-Activity.Width/2 'left
Dim r As Int = (bm.Width/2)+Activity.Width/2 'right
Dim t As Int = (bm.height/2)-Activity.height/2 'top
Dim b As Int = (bm.height/2)+Activity.height/2 'bottom
'source middle of Panorama
srect.Initialize(l,t,r,b)
drect.Initialize(0,0, Activity.width, Activity.Height)
can.DrawBitmap( bm, srect,drect)
End Sub
Sub Activity_Resume
Accelerometer.StartListening("Accelerometer")
End Sub
Sub Activity_Pause (UserClosed As Boolean)
Accelerometer.StopListening
End Sub
Sub Accelerometer_AccelerometerChanged (X As Float, Y As Float, Z As Float)
Log (x & " " & Y & " " & Z)
srect.Left = srect.Left - (y*100)
'avoid negative values of left
If srect.Left < 0 Then
srect.Left = 0
srect.right = Activity.width
Return
End If
srect.right = srect.right -(y*100)
'avoid values > imagewidth for right
If srect.right > bm.width Then
srect.Left = bm.width-Activity.Width
srect.right = bm.width
Return
End If
can.DrawBitmap( bm, srect,drect)
Activity.Invalidate
End Sub