I was wondering if anyone has tried to use AndEngine in B4A?
- Scott
- Scott
public class AndEngineWrapper extends BaseGameActivity {
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
'Declaration of Variables
Dim Lives, Hitpoints As Int
Dim CameraWidth, CameraHeight As Int
'Declaration of Views
Dim pnlGame As Panel
Dim vwRender As RSRenderView
'Declaration of Libraries
Dim Engine As AndEngine
Dim Camera As AndCamera
Dim Scene As AndScene
Dim Constants As AndConstants
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Load Activity Stuff
Activity.LoadLayout("Game.bal")
'Initialize variables
Lives = 3
Hitpoints = 100
CameraWidth = pnlGame.Width
CameraHeight = pnlGame.Height
'Initialize views
vwRender.Initialize("RenderView")
'Initialize AndEngine
LoadEngine
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
'Loads the AndEngine
Sub LoadEngine
'First we need a Camera Object
'A Camera object is needed as a holder of the enginer. See like a panel
Camera.Initialize("Camera", CameraWidth, CameraHeight)
'Next we will create a scene
'A scene is the object where we will draw on. See like a canvas
Scene.Initialize("Scene")
Scene.setBackgroundColor(123, 231,5)
'Initializes the AndEngine which passes the camera and the screen orientation.
'The width and height are extracted from the camera.
Engine.Orientation = Constants.ORIENTATION_LANDSCAPE
Engine.Initialize("Engine", Camera.Camera, Engine.Orientation)
'Checks to be certain that some variabels are not null. - Debugging.
Engine.isNull(Engine.Engine)
Engine.isNull(Camera.Camera)
Engine.isNull(vwRender)
'Starts the Engine
Engine.start
'We pass the Scene to the Engine.
Engine.Scene = Scene.Scene
'We set the RenderView to render the Engine
vwRender.Renderer = Engine.Engine
'Now let's try to add the Engine to the Panel
'pnlGame.AddView(vwRender, 0dip, 0dip, 100%x, 100%y)
'----Here's where i'm currently stuck at. ---------
StartActivity(Engine.CreateIntent)
End Sub
Whats the issue in starting an activity?
You need to add it to the manifest editor.