Hello all,
I am trying to implement the use of a full screen game for a game I am working on.
I have the following code found in the project: PlayCanvas | HTML5 Game Engine
var FullScreen = pc.createScript('fullScreen');
FullScreen.attributes.add("fullScene", { type: 'boolean', default: false });
// initialize code called once per entity
FullScreen.prototype.initialize = function () {
// this.app.graphicsDevice.fullscreen = true; // enter fullscreen
this.fullScreenButton = this.entity.findByName("fullScreenButton");
this.fullScreenButton.button.on('click', function(e) {
toggleFullScreen();
// goFullScreen();
}, this);
};
function toggleFullScreen() {
console.log("DEBUG: Toggling Fullscreen ", document.fullscreenElement);
if (!document.fullscreenElement) {
let element = document.body;
let requestFSFunction = element.requestFullScreen || element.webkitRequestFullscreen || element.webkitRequestFullScreen || document.requestFullscreen || document.msRequestFullscreen || document.mozRequestFullScreen;
if (requestFSFunction) {
requestFSFunction.apply(element);
}
else {
// element.requestFullScreen();jhvhgv
console.log("ERR:", "Fullscreen failed!");
}
}
else {
document.exitFullscreen();
// console.log("DEBUG:",this.entity.findByTag("buttonText"));
}
}
This supports fullscreen for my laptop, but not a mobile device, more specifically, an iOS device.
Any ideas?
Thank you and regards,
Adam Burgess