You are on page 1of 3

3/21/2014

JetLab Games Blog | HTML5 gamedev

JetLab Games Blog


HTML5 gamedev

FGL API and Haxe 0 Comments


It is very easy to integrate any side API to Haxe project. For example - I recently played with brand new FGL.com API (see at https://www.fgl.com/other/html5opportunities/) As you know - Haxe provides very powerful method of condition compilation - you can include or exclude parts of code using flags, provided to compiler at build time. This method allows to build game for every site and every API from one single code source. Very short example of usage:
1 2 3 4 5 6 7 8 9 # i ff g l i n i t F g l A P I ( ) ; # e n d # i fs o f t g a m e s i n i t S o f t G a m e s A P I ( ) ; # e n d / / a n ds oo n . . .

At first you should rewrite common flambe embedder code. Unfortunately, this part is not automated by Haxe:)
1 2 3 4 5 6 7 8 9 < s c r i p tt y p e = " t e x t / j a v a s c r i p t "s r c = " f l a m b e . j s " > < / s c r i p t > < s c r i p tt y p e = " t e x t / j a v a s c r i p t "s r c = " f g l . j s " > < / s c r i p t > < s c r i p tt y p e = " t e x t / j a v a s c r i p t " > f g l . c r e a t e ( d o c u m e n t . g e t E l e m e n t B y I d ( " c o n t e n t " ) ," c o m . j e t l a b . g e m c r u s h " ) ; f g l . o n R e a d y ( f u n c t i o n ( ) { f l a m b e . e m b e d ( [ " t a r g e t s / m a i n h t m l . j s " ] ," c o n t e n t " ) ; } ) ; < / s c r i p t >

Do not forget to put fgl.js file in your project folder. To create a "More Games" button on your game title - use example below. Add to Title.hx:
1 2 3 # i ff g l p r i v a t ev a r_ m o r e g a m e s _ b u t t o n : E n t i t y ; # e n d
1/3

https://blog.jetlab-games.com/

3/21/2014

JetLab Games Blog | HTML5 gamedev

4 5 6 7 8 9 1 0 1 1 1 2 1 3 1 4

p u b l i cf u n c t i o ns h o w T i t l e ( ) { # i ff g l b=n e wB u t t o n ( 1 0 , 1 0 , 3 0 0 , 3 0 0 ,_ p a c k ) _ m o r e g a m e s _ b u t t o n=n e wE n t i t y ( ) ; b . r e g i s t e r C l i c k V o i d A c t i o n ( f u n c t i o n ( ){u n t y p e d_ _ j s _ _ ( " f g l . s h o w M o r e G a m e s ( ) " ) _ m o r e g a m e s _ b u t t o n . a d d C h i l d ( b ) _ r o o t . a d d C h i l d ( _ m o r e g a m e s _ _ b u t t o n ) ; # e n d / / o t h e rc o d e

To show advertisement (for example - at level end) add to Game.hx:


1 p u b l i cf u n c t i o nl e v e l E n d ( ) 2 { 3 # i ff g l 4 u n t y p e d_ _ j s _ _ ( " f g l . s h o w A d ( ) " ) ; 5 # e n d 6 / / c o m p l e t el e v e lc o d e 7 }

To enable all code defined inside (#if fgl) blocks you should set this option in project file (flambe.yaml) like this:
1 2 3 #A d d i t i o n a lf l a g st op a s st ot h eH a x ec o m p i l e r #h a x e _ f l a g s :l i bn a p eDf o o b a r h a x e _ f l a g s :Df g l

or you can set -D fgl option directly to compiler in command line at a build time. You can check results of this guide here: http://blog.jetlab-games.com/gemcrush/index-fgl.html Posted in gamedev and tagged Flambe, Haxe on December 21, 2013 [https://blog.jetlabgames.com/2013/12/fgl-api-and-haxe/] by jetlab.

Flambe disable WebGL 0 Comments


To disable WebGL in flambe project - enable option -D flambe_disable_webgl in project file (flambe.yaml) Example:
1 #A d d i t i o n a lf l a g st op a s st ot h eH a x ec o m p i l e r
https://blog.jetlab-games.com/ 2/3

3/21/2014

JetLab Games Blog | HTML5 gamedev

2 #h a x e _ f l a g s :l i bn a p eDf o o b a r 3 h a x e _ f l a g s :Df l a m b e _ d i s a b l e _ w e b g l

Posted in gamedev and tagged Flambe, Haxe on December 20, 2013 [https://blog.jetlabgames.com/2013/12/flambe-disable-webgl/] by jetlab.

https://blog.jetlab-games.com/

3/3

You might also like