development <<< openfl syntax
TextField - input text field with softkeyboard for android haxe conditions compilation(#if android)
import flixel.addons.ui.FlxInputText;
import openfl.text.TextField;
import openfl.text.TextFormatAlign;
class StatS extends FlxState {
var uname:FlxInputText;
var muname:TextField;
function onMobileEnter(e:openfl.events.KeyboardEvent){
if (e.keyCode == 13) {
muname.__dismissSoftKeyboard();
muname.removeEventListener(openfl.events.KeyboardEvent.KEY_DOWN, onMobileEnter);
FlxG.removeChild(muname);
}
}
function namemaker():Void
{
#if mobile
muname=new TextField();
muname.x=10;
muname.y=160;
muname.type = openfl.text.TextFieldType.INPUT;
muname.textColor=0x00FFFF;
muname.border=true;
muname.borderColor=0x00FFFF;
muname.background=false;
muname.backgroundColor=0x000000;
muname.width=700;
muname.height=60;
muname.defaultTextFormat = new openfl.text.TextFormat("assets/data/RobotoMono-Bold.ttf", 32,0x00FFFF,false,false,false,null,null,TextFormatAlign.CENTER);
muname.needsSoftKeyboard = true;
muname.addEventListener(openfl.events.KeyboardEvent.KEY_DOWN, onMobileEnter);
muname.maxChars=11;
muname.text="noname";
FlxG.addChildBelowMouse(muname);
#else
uname=new FlxInputText(0,160,720,"touch",60,FlxColor.WHITE,FlxColor.BLACK);
uname.filterMode=3;
uname.lines=1;
uname.maxLength=11;
uname.caretColor=FlxColor.WHITE;
add(uname);
#end
}
public override function create():Void {
super.create();
namemaker();//textfield depend of android || other
}
}
github link "extension-wake-lock" Turn off/on screen autolock for android target
console
haxelib install extension-wake-lock
"Enter". Then
addon in "Project.xml"
<haxelib name="extension-wake-lock" />
Then inside source code, for example, inside "override public function create()" of PlayState.hx
override public function create():Void{
super.create();
extension.wakeLock.WakeLock.allowScreenTimeout = false; // to disable screen Lock
extension.wakeLock.WakeLock.allowScreenTimeout = true; // to enable screen Lock
... }