Files
GDevelop/Extensions/TextEntryObject/textentryruntimeobject-cocos-renderer.js
T
Florian Rival aa7a4a4ff3 Rename onOwnerRemovedFromScene to onDestroy and fix onCreated/onDestroy calls
* Rename onOwnerRemovedFromScene to onDestroy (because it can be now called when a scene is destroyed)
* Fix it being not called when a scene is destroyed (so behavior don't get a chance to clean up what they have created)
* Fix onCreated being called before the object is fully initialized (for custom behaviors or behaviors relying on an object type)
2019-07-28 17:43:50 +01:00

38 lines
1.2 KiB
JavaScript

gdjs.TextEntryRuntimeObjectCocosRenderer = function(runtimeObject, runtimeScene)
{
this._object = runtimeObject;
this._textField = new cc.TextFieldTTF('', cc.size(500,150), cc.TEXT_ALIGNMENT_LEFT,"Arial", 32);
this._textField.setOpacity(0);
var renderer = runtimeScene.getLayer("").getRenderer();
renderer.addRendererObject(this._textField, runtimeObject.getZOrder());
this.updateString();
};
gdjs.TextEntryRuntimeObjectRenderer = gdjs.TextEntryRuntimeObjectCocosRenderer; //Register the class to let the engine use it.
gdjs.TextEntryRuntimeObjectCocosRenderer.prototype.onDestroy = function() {
this.activate(false);
};
gdjs.TextEntryRuntimeObjectCocosRenderer.prototype.getRendererObject = function() {
return this._textField;
};
gdjs.TextEntryRuntimeObjectCocosRenderer.prototype.getString = function() {
return this._textField.getString();
}
gdjs.TextEntryRuntimeObjectCocosRenderer.prototype.updateString = function() {
this._textField.setString(this._object.getString());
}
gdjs.TextEntryRuntimeObjectCocosRenderer.prototype.activate = function(enable) {
if (enable) {
this._textField.attachWithIME();
} else {
this._textField.detachWithIME();
}
}