Ola
UPDATE: 2019-11-20 Complete Rewrite
You can also checkout BreakOut here, created with BANanoPhaser also.
With this game we will have our alien who will collect stars and dodge some bombs. We will be able to make him jump and run. We will just create a simple level here.
This was featured here, so here we will go about creating it. After we have done this tut, we will be able to create this game.
NB: The project uses a tweaked version of the BANanoPostProcessor (attached) its not compulsory, you can remove the reference to it.
Details about the Phaser Game Engine are here.
PREPARING THE GAME
1. Step 1, let's get our game space ready. As indicated in this post, we need to have our Preload, Create, and Update events ready. We initialize a scene so that we can have everything in order.
1.1 We preload our resources onPreload
1.2 onCreate we actually code our game
1.3 onUpdate is where the animations / FPS fire and we perform stuff in our game.
This game is on the pgStarCatcher module attached herein.
In Process globals we define some variables for our game..
We then create the skeleton for our game.
UPDATE: 2019-11-20 Complete Rewrite
You can also checkout BreakOut here, created with BANanoPhaser also.
With this game we will have our alien who will collect stars and dodge some bombs. We will be able to make him jump and run. We will just create a simple level here.
This was featured here, so here we will go about creating it. After we have done this tut, we will be able to create this game.
NB: The project uses a tweaked version of the BANanoPostProcessor (attached) its not compulsory, you can remove the reference to it.
Details about the Phaser Game Engine are here.
PREPARING THE GAME
1. Step 1, let's get our game space ready. As indicated in this post, we need to have our Preload, Create, and Update events ready. We initialize a scene so that we can have everything in order.
1.1 We preload our resources onPreload
1.2 onCreate we actually code our game
1.3 onUpdate is where the animations / FPS fire and we perform stuff in our game.
This game is on the pgStarCatcher module attached herein.
In Process globals we define some variables for our game..
B4X:
Private game As BANanoPhaser
Private body As BANanoElement
Private Scene As PhaserScene
We then create the skeleton for our game.
B4X:
Sub Init
'set the body of the page
body = BANano.GetElement("#body")
body.SetStyle(BANano.ToJson(CreateMap("margin":"0")))
body.Empty
'add the div to set the game in
'lets set up the game
'initialze the game, use game element and set size
game.Initialize
'The Type can be Phaser.CANVAS, Phaser.WEBGL Or Phaser.AUTO. AUTO means that
'Phaser will Try To render with WebGL, And fall back To Canvas If it fails
game.SetTypeAuto(True)
'element to inject the game in
game.SetParent("body")
game.SetWidth(800)
game.SetHeight(640)
'Ensure the canvas is resized to fit the parent div's dimensions
game.SetScaleMode(game.ScaleModeRESIZE)
'Center the game canvas both horizontally and vertically within the parent
game.SetScaleAutoCenter(game.ScaleCenterCENTER_BOTH)
'The physics engine determines how objects interact with the world. Phaser
'supports three physics engines out of the box: arcade, impact and matter.
' Arcade is understood to be the simplest one to implement
game.SetPhysicsDefault("arcade")
'create a scene there can be multiple scenes in the same game
Scene = game.CreateScene("starCatcher")
'steps in the game scene to execute
Scene.SetOnPreload(Me, "onPreLoad")
Scene.SetOnCreate(Me, "onCreate")
Scene.SetOnUpdate(Me, "onUpdate")
game.SetScene(Scene.Scene)
'
game.Start
End Sub
Sub onPreload
End Sub
Sub OnCreate
End Sub
Sub onUpdate
End Sub
Attachments
Last edited: