Last active
December 16, 2015 14:59
-
-
Save dimitarcl/5452402 to your computer and use it in GitHub Desktop.
Coherent UI 1.2.1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Coherent.UI; | |
using Coherent.UI.Binding; | |
namespace MyGame | |
{ | |
class Options | |
{ | |
public bool SetWindowSize(int width, int height); | |
} | |
class MyGame | |
{ | |
Options m_Options; | |
BoundObject GetOptionsForUI() | |
{ | |
// wrap m_Options so its methods are exported | |
return BoundObject.BindMethods(m_Options); | |
} | |
void OnViewReady(View view) | |
{ | |
view.BindCall("getOptions", this.GetOptionsForUI); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
engine.call('getOptions') | |
.then(function (options) { | |
return options.SetWindowSize(1920, 1280); | |
}) | |
.then(function (result) { | |
// chaining of promises works so | |
// result is the boolean returned by m_Options.SetWindowSize | |
if (result) { | |
console.log('resolution changed') | |
} else { | |
console.error('could not change resolution'); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment