B4i Library iGameView - Library for games

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

upload_2016-9-6_14-24-21.png

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
This is an alternative to B4A Bitmap.InitializeMutable method.

If you are using the hosted builder then only the XML file is required.
 

Attachments

  • upload_2016-9-6_14-23-44.png
    upload_2016-9-6_14-23-44.png
    24.9 KB · Views: 24
  • GameViewSmiley.zip
    20.3 KB · Views: 65
  • JumpingSmiley.zip
    24.3 KB · Views: 57
  • Asteroids.zip
    249.7 KB · Views: 67
Last edited:

sorex

Expert
Licensed User
Longtime User
does this contain any acceleration or is everything on IOS accelerated anyway?
 

sorex

Expert
Licensed User
Longtime User
When I try my project that ran fine on my IOS9 device at work on my IOS7 device at home I get an immediate crash without any info in the log window.

Is iGameView also requiring IOS9 or better like iSpritekit does (also crashes) ?
 

sorex

Expert
Licensed User
Longtime User
The phone is at home so I can only test things tonight.

I didn't disabled it myself so it's probably still on.

It also turns out it's an iphone 4 and nothe 4S I thought it was so I'm stuck on 7.1.2 or something.
I have a 5 or 5S at home aswell but I don't know on what it is running will verify it on that one aswell.
 

sorex

Expert
Licensed User
Longtime User
now it's working fine. without touching the source.
 
Top