Andrzej Mazur — @end3r — Enclave Games
Hungarian Web Conference — Budapest, Hungary — November 8th 2014
WebTelephony, Vibration API, WebSMS, Idle API, Screen Orientation, Settings API, Power Management API, Mobile Connection API, TCP Socket API, Geolocation API, WiFi Information API, Device Storage API, Contacts API, Mouse Lock API, Open WebApps, WebBluetooth, Network Information API, Battery Status API, Alarm API, Browser API, Time⁄Clock API, Web Activities, Push Notifications API, Permissions API, WebFM API, FileHandle API, Network Stats API, WebPayment, IndexedDB, Archive API, Ambient light sensor, Proximity sensor, SystemXHR, ...
window.navigator.vibrate(200);
checkOrientation = function() {
if(window.orientation == 0 || window.orientation == 180) {
// "rotate your device"
}
else {
// "keep playing"
}
}
document.addEventListener("visibilitychange", function() {
if(document.hidden) {
// "app is not visible"
}
else {
// "app is visible"
}
})
"permissions": {
"contacts": {
"description": "Required for autocompletion in the share screen",
"access": "readcreate"
},
"alarms": {
"description": "Required to schedule notifications"
}
}
Firefox OS game == HTML5 game
ctx.drawImage(myImage, 0.3, 0.5);
myEntity.offscreenCanvas = document.createElement(“canvas”);
myEntity.offscreenCanvas.width = myEntity.width;
myEntity.offscreenCanvas.height = myEntity.height;
myEntity.offscreenContext = myEntity.offscreenCanvas.getContext(“2d”);
myEntity.render(myEntity.offscreenContext);
<canvas id="mycanvas" moz-opaque></canvas>
var scaleX = canvas.width / window.innerWidth;
var scaleY = canvas.height / window.innerHeight;
var scaleToFit = Math.min(scaleX, scaleY);
var scaleToCover = Math.max(scaleX, scaleY);
stage.style.transformOrigin = "0 0"; //scale from top left
stage.style.transform = "scale(" + scaleToFit + ")";
Optimize for HTML5 games,
Firefox OS support will come along the way
App Manager
about:app-manager
Freedom
var installapp = navigator.mozApps.install(manifestURL);
installapp.onsuccess = function(data) {
// "App was installed"
};
installapp.onerror = function() {
// "App was NOT installed,
// check the installapp.error.name for more info"
}
manifest.webapp
{
"name": "Name of the app",
"description": "Description of the app",
"launch_path": "/",
"icons": {
"128": "/img/icon-128.png"
},
"developer": {
"name": "Enclave Games",
"url": "http://enclavegames.com"
},
"default_locale": "en"
}