upload matchn game
Browse files- matchn/MatchNGame.html +1 -1
- matchn/gameapp.js +15 -10
matchn/MatchNGame.html
CHANGED
|
@@ -142,7 +142,7 @@
|
|
| 142 |
<script type='text/javascript' src='MatchNGame.js'></script>
|
| 143 |
<script type='text/javascript'>//<![CDATA[
|
| 144 |
|
| 145 |
-
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":0,"executable":"MatchNGame","experimentalVK":false,"fileSizes":{"MatchNGame.pck":
|
| 146 |
var engine = new Engine(GODOT_CONFIG);
|
| 147 |
|
| 148 |
(function() {
|
|
|
|
| 142 |
<script type='text/javascript' src='MatchNGame.js'></script>
|
| 143 |
<script type='text/javascript'>//<![CDATA[
|
| 144 |
|
| 145 |
+
const GODOT_CONFIG = {"args":[],"canvasResizePolicy":0,"executable":"MatchNGame","experimentalVK":false,"fileSizes":{"MatchNGame.pck":55475600,"MatchNGame.wasm":19761972},"focusCanvas":true,"gdnativeLibs":[]};
|
| 146 |
var engine = new Engine(GODOT_CONFIG);
|
| 147 |
|
| 148 |
(function() {
|
matchn/gameapp.js
CHANGED
|
@@ -73,13 +73,16 @@ function confirmSelectFile(accept = "all") {
|
|
| 73 |
document.querySelector("body").appendChild(div);
|
| 74 |
}
|
| 75 |
|
|
|
|
|
|
|
|
|
|
| 76 |
function userInput(_text) {
|
| 77 |
if (window.input_div == null){
|
| 78 |
const div = document.createElement("div");
|
| 79 |
window.input_div = div
|
| 80 |
div.setAttribute(
|
| 81 |
"style",
|
| 82 |
-
"width:
|
| 83 |
);
|
| 84 |
const inputContianer = document.createElement("div");
|
| 85 |
inputContianer.setAttribute("style", "display:flex;width:100%;box-sizing:border-box;padding:10px 15px;");
|
|
@@ -88,9 +91,8 @@ function userInput(_text) {
|
|
| 88 |
input.type = "text";
|
| 89 |
input.setAttribute(
|
| 90 |
"style",
|
| 91 |
-
"display:block;width:100%;
|
| 92 |
);
|
| 93 |
-
|
| 94 |
// 设置输入框的默认值为传入的参数 _text
|
| 95 |
input.value = _text || ""; // 如果 _text 是 undefined 或者 null,默认设置为空
|
| 96 |
|
|
@@ -103,22 +105,25 @@ function userInput(_text) {
|
|
| 103 |
// buttonContianer.appendChild(confirmButton);
|
| 104 |
div.appendChild(buttonContianer);
|
| 105 |
document.querySelector("body").appendChild(div);
|
| 106 |
-
|
| 107 |
-
// 获取焦点
|
| 108 |
input.addEventListener("input", ()=>{
|
| 109 |
const value = input.value;
|
| 110 |
window.godotUserInput(value); //将输入传递给Godot
|
| 111 |
});
|
| 112 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
// 失去焦点
|
| 114 |
input.addEventListener("blur", () => {
|
| 115 |
div.remove();
|
| 116 |
window.input_div = null;
|
| 117 |
-
isInputFocused = false;
|
| 118 |
});
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
|
|
|
| 122 |
}
|
| 123 |
}
|
| 124 |
|
|
|
|
| 73 |
document.querySelector("body").appendChild(div);
|
| 74 |
}
|
| 75 |
|
| 76 |
+
let number = 0
|
| 77 |
+
window.input_div
|
| 78 |
+
window.user_input
|
| 79 |
function userInput(_text) {
|
| 80 |
if (window.input_div == null){
|
| 81 |
const div = document.createElement("div");
|
| 82 |
window.input_div = div
|
| 83 |
div.setAttribute(
|
| 84 |
"style",
|
| 85 |
+
"width: 100%;display: flex;flex-direction: column;position: fixed;bottom: 0%;left: 50%;transform: translate(-50%, 0%); background:block;box-shadow:0 0px 4px 4px #00000033;border-radius:5px;overflow:hidden;z-index:99;opacity:0"
|
| 86 |
);
|
| 87 |
const inputContianer = document.createElement("div");
|
| 88 |
inputContianer.setAttribute("style", "display:flex;width:100%;box-sizing:border-box;padding:10px 15px;");
|
|
|
|
| 91 |
input.type = "text";
|
| 92 |
input.setAttribute(
|
| 93 |
"style",
|
| 94 |
+
"display:block;width:100%;border:1px solid #007aff;border-radius:2px;font-size:16px;height:200px;line-height:28px;padding:0 5px;"
|
| 95 |
);
|
|
|
|
| 96 |
// 设置输入框的默认值为传入的参数 _text
|
| 97 |
input.value = _text || ""; // 如果 _text 是 undefined 或者 null,默认设置为空
|
| 98 |
|
|
|
|
| 105 |
// buttonContianer.appendChild(confirmButton);
|
| 106 |
div.appendChild(buttonContianer);
|
| 107 |
document.querySelector("body").appendChild(div);
|
| 108 |
+
// 输入
|
|
|
|
| 109 |
input.addEventListener("input", ()=>{
|
| 110 |
const value = input.value;
|
| 111 |
window.godotUserInput(value); //将输入传递给Godot
|
| 112 |
});
|
| 113 |
+
// 获取焦点
|
| 114 |
+
input.addEventListener("focus", ()=>{
|
| 115 |
+
number += 1
|
| 116 |
+
div.style.left = "-999999px";
|
| 117 |
+
});
|
| 118 |
// 失去焦点
|
| 119 |
input.addEventListener("blur", () => {
|
| 120 |
div.remove();
|
| 121 |
window.input_div = null;
|
|
|
|
| 122 |
});
|
| 123 |
+
if (number >0){
|
| 124 |
+
input.focus();
|
| 125 |
+
input.click();
|
| 126 |
+
}
|
| 127 |
}
|
| 128 |
}
|
| 129 |
|