B4J Question [BANAno] [SOLVED] Javascript to BANano - How to initialize a new function?

Mashiane

Expert
Licensed User
Longtime User
Hi there

Just hit a wall...

B4X:
var FizzyText = function() {
  this.message = 'dat.gui';
  this.speed = 0.8;
  this.displayOutline = false;
  this.explode = function() { ... };
  // Define render logic ...
};

window.onload = function() {
  var text = new FizzyText();
  var gui = new dat.GUI();
  gui.add(text, 'message');
  gui.add(text, 'speed', -5, 5);
  gui.add(text, 'displayOutline');
  gui.add(text, 'explode');
};

I'm assuming

B4X:
Sub FizzyText
    Dim message As String = "dat.gui"
    Dim speed As Double = 0.08
    Dim displayOutline As Boolean = False
End Sub

but then how do I declare the call for,
B4X:
var text = new FizzyText();

works and is able to have the variables defined in that sub available?

The test of the part, seems fairly understandable..

B4X:
Dim gui As BANanoObject
gui.Initialize2("dat.GUI", Null)
gui.RunMethod("add", array(text, "message"))
....

I'm trying

B4X:
Dim text as BANanoObject
text.Initialize2("FizzyText", null)
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…