Sub Activity_KeyPress (KeyCode As Int) As Boolean
'Right arrow
If Keycode = KeyCodes.KEYCODE_DPAD_RIGHT Then
blnFacing = True 'sets the sprite to look right.
CharMoveRight
End If
'Left arrow
If Keycode = KeyCodes.KEYCODE_DPAD_LEFT Then
blnFacing = False 'sets the sprite to look left.
CharMoveLeft
End If
'Cross button
If Keycode = 23 Then
isjumping = False
vely = 100
CharJump
End If
'Circle button
'If Keycode = 4 Then
' Return True
'End If
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub Activity_Resume
End Sub
Sub CharMoveRight
If blnFacing = True Then
Rect.Top = y
Rect.Left = x
Rect.Bottom = y + boxSize
Rect.Right = x + boxSize
Canvas1.DrawBitmap(Bitmap1, Rect, Rect) 'Erase the previous character
Activity.Invalidate2(Rect)
x = x + vx
y = y
Rect.Top = y
Rect.Left = x
Rect.Bottom = y + boxSize
Rect.Right = x + boxSize
Canvas1.DrawBitmap(btmChar, Null, Rect) 'Draw the new character
Activity.Invalidate2(Rect)
blnFacing = False
Else
Rect.Top = y
Rect.Left = x
Rect.Bottom = y + boxSize
Rect.Right = x + boxSize
Canvas1.DrawBitmap(Bitmap1, Rect, Rect) 'Erase the previous character
Activity.Invalidate2(Rect)
x = x + vx
y = y
Rect.Top = y
Rect.Left = x
Rect.Bottom = y + boxSize
Rect.Right = x + boxSize
Canvas1.DrawBitmapFlipped(btmChar, Null, Rect,False,True) 'Draw the new character
Activity.Invalidate2(Rect)
blnFacing = False
End If
End Sub
Sub CharMoveLeft
If blnFacing = False Then
Rect.Top = y
Rect.Left = x
Rect.Bottom = y + boxSize
Rect.Right = x + boxSize
Canvas1.DrawBitmap(Bitmap1, Rect, Rect) 'Erase the previous smiley
Activity.Invalidate2(Rect)
x = x - vx
y = y
Rect.Top = y
Rect.Left = x
Rect.Bottom = y + boxSize
Rect.Right = x + boxSize
Canvas1.DrawBitmapFlipped(btmChar, Null, Rect,False,True) 'Draw the new smiley
Activity.Invalidate2(Rect)
blnFacing = True
Else
Rect.Top = y
Rect.Left = x
Rect.Bottom = y + boxSize
Rect.Right = x + boxSize
Canvas1.DrawBitmap(Bitmap1, Rect, Rect) 'Erase the previous smiley
Activity.Invalidate2(Rect)
x = x - vx
y = y
Rect.Top = y
Rect.Left = x
Rect.Bottom = y + boxSize
Rect.Right = x + boxSize
Canvas1.DrawBitmap(btmChar, Null, Rect) 'Draw the new smiley
Activity.Invalidate2(Rect)
blnFacing = True
End If
End Sub