iGameView is a port of B4A GameView library: https://www.b4x.com/android/forum/threads/gameview-create-2d-android-games-part-i.20038/
It also includes methods for low latency audio playback, similar to B4A SoundPool. These features are based on the following open source project: https://github.com/kstenerud/ObjectAL-for-iPhone (see the license in the readme).
You can use the audio playback features without the GameView drawing features.
Three examples are included:
GameViewSmiley: simple example with no interaction
Jumping smiley: vertical scrolling game where the user controls the smiley by tilting the phone.
Asteroids: classic asteroids example. This also includes a game pad class.
You should start by going over the B4A tutorials. The main concepts are the same.
https://www.b4x.com/android/forum/threads/gameview-create-2d-android-games-part-i.20038/
Tips & notes
- The B4A examples use %x / %y for most measurements. In B4i you should only use percentage inside Page_Resize event. As an alternative we handle the Page1_Resize event once and store the page width and height. Note that all of the layout is set in the first resize event.
- B4i Rect object stores the values as floats while B4A Rect object stores the values as Ints. You can use Round to round the values before they are set.
- Performance should be tested in release mode (Alt + T + B + R).
If it starts to be very slow in debug mode then stop the program, click on Ctrl + P (clean project) and run again.
The performance in release mode should be good. It can handle several hundred sprites.
- You will see in the examples that I'm using this sub to create canvas objects:
This is an alternative to B4A Bitmap.InitializeMutable method.
If you are using the hosted builder then only the XML file is required.
It also includes methods for low latency audio playback, similar to B4A SoundPool. These features are based on the following open source project: https://github.com/kstenerud/ObjectAL-for-iPhone (see the license in the readme).
You can use the audio playback features without the GameView drawing features.
Three examples are included:
GameViewSmiley: simple example with no interaction
Jumping smiley: vertical scrolling game where the user controls the smiley by tilting the phone.
Asteroids: classic asteroids example. This also includes a game pad class.
You should start by going over the B4A tutorials. The main concepts are the same.
https://www.b4x.com/android/forum/threads/gameview-create-2d-android-games-part-i.20038/
Tips & notes
- The B4A examples use %x / %y for most measurements. In B4i you should only use percentage inside Page_Resize event. As an alternative we handle the Page1_Resize event once and store the page width and height. Note that all of the layout is set in the first resize event.
- B4i Rect object stores the values as floats while B4A Rect object stores the values as Ints. You can use Round to round the values before they are set.
- Performance should be tested in release mode (Alt + T + B + R).
If it starts to be very slow in debug mode then stop the program, click on Ctrl + P (clean project) and run again.
The performance in release mode should be good. It can handle several hundred sprites.
- You will see in the examples that I'm using this sub to create canvas objects:
B4X:
'don't forget to release when done
Public Sub CreateCanvas (width1 As Int, height1 As Int) As Canvas
Dim iv As ImageView
iv.Initialize("")
iv.SetLayoutAnimated(0, 1, 0, 0, width1, height1)
Dim c As Canvas
c.Initialize(iv)
Return c
End Sub
If you are using the hosted builder then only the XML file is required.
Attachments
Last edited: