PIXI Controls: Debug enable button
This commit is contained in:
parent
03775afea1
commit
b5d5cc6c89
3 changed files with 42 additions and 0 deletions
|
@ -25,6 +25,7 @@ ONSControls.createCanvas = function() {
|
||||||
transparent: true
|
transparent: true
|
||||||
});
|
});
|
||||||
document.body.appendChild(canvas.view);
|
document.body.appendChild(canvas.view);
|
||||||
|
canvas.view.id = "ControlsCanvas";
|
||||||
canvas.view.style.zIndex = this.options.zIndex;
|
canvas.view.style.zIndex = this.options.zIndex;
|
||||||
canvas.view.style.position = "absolute";
|
canvas.view.style.position = "absolute";
|
||||||
canvas.view.style.left = 0;
|
canvas.view.style.left = 0;
|
||||||
|
@ -150,6 +151,19 @@ ONSControls.sendEvent = function(event, button) {
|
||||||
const key = VirtualGamepad.keys.find((element) => element.name == button);
|
const key = VirtualGamepad.keys.find((element) => element.name == button);
|
||||||
VirtualGamepad.gamepad.buttons[key.code].pressed = event.type == "pointerdown" ? true : false
|
VirtualGamepad.gamepad.buttons[key.code].pressed = event.type == "pointerdown" ? true : false
|
||||||
}
|
}
|
||||||
|
//=============================================================================
|
||||||
|
// * Fix controls size on empty screen
|
||||||
|
//=============================================================================
|
||||||
|
document.addEventListener("deviceready", onCordovaDeviceReady, false);
|
||||||
|
|
||||||
|
ONSControls.onCordovaDeviceReady = function () {
|
||||||
|
console.log("ONSControls - SETUP!!!"); //Remove in release
|
||||||
|
document.addEventListener("resume", onCordovaResume, false);
|
||||||
|
};
|
||||||
|
|
||||||
|
ONSControls.onCordovaResume = function () {
|
||||||
|
// TODO: HERE CONTROLS WILL BE UPDATED OR RECREATED
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,15 @@
|
||||||
z-index: 1489;
|
z-index: 1489;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.new-button {
|
||||||
|
position: absolute;
|
||||||
|
right: 5px;
|
||||||
|
top: 5px;
|
||||||
|
width: 90px;
|
||||||
|
height: 40px;
|
||||||
|
z-index: 1489;
|
||||||
|
}
|
||||||
|
|
||||||
.gamepad-buttons {
|
.gamepad-buttons {
|
||||||
opacity: 0.6;
|
opacity: 0.6;
|
||||||
z-index: 1488;
|
z-index: 1488;
|
||||||
|
|
|
@ -66,6 +66,24 @@ function create_fps_button() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function create_new_controls() {
|
||||||
|
// Remove in release
|
||||||
|
const NewBtn = document.createElement("div");
|
||||||
|
NewBtn.className = "new-button";
|
||||||
|
document.body.appendChild(NewBtn);
|
||||||
|
|
||||||
|
NewBtn.addEventListener("pointerdown", () => {
|
||||||
|
var controls_canvas = document.getElementById("ControlsCanvas");
|
||||||
|
if (controls_canvas === null) {
|
||||||
|
document.getElementById("show-gamepad").remove();
|
||||||
|
ONSControls.initialize();
|
||||||
|
} else {
|
||||||
|
controls_canvas.remove();
|
||||||
|
create_show_button();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function create_dpad_buttons() {
|
function create_dpad_buttons() {
|
||||||
// Скуфting elements
|
// Скуфting elements
|
||||||
const DivDMain = document.createElement("div");
|
const DivDMain = document.createElement("div");
|
||||||
|
@ -283,6 +301,7 @@ function setupKey(id, key, keyCode) {
|
||||||
|
|
||||||
window.addEventListener('load', () => {
|
window.addEventListener('load', () => {
|
||||||
create_fps_button(); // Remove in release
|
create_fps_button(); // Remove in release
|
||||||
|
create_new_controls(); // Remove in release
|
||||||
if (navigator.getGamepads().length == 0) {
|
if (navigator.getGamepads().length == 0) {
|
||||||
create_control_buttons();
|
create_control_buttons();
|
||||||
create_dpad_buttons();
|
create_dpad_buttons();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue