topical media & game development
mobile-graphic-enchant-dev-src-Env.js / js
@namespace
[lang:ja]
enchant.js の環境変数.
new Core() を呼ぶ前に変更することで変更することで, 動作設定を変えることができる.
[/lang]
[lang:en]
Environment variable.
[/lang]
[lang:de]
Umgebungsvariable.
[/lang]
@type {Object}
enchant.ENV = {
Version of enchant.js
@type {String}
VERSION: "0.6.1",
The CSS vendor prefix of the current browser.
@type {String}
VENDOR_PREFIX: (function() {
var ua = navigator.userAgent;
if (ua.indexOf('Opera') !== -1) {
return 'O';
} else if (ua.indexOf('MSIE') !== -1) {
return 'ms';
} else if (ua.indexOf('WebKit') !== -1) {
return 'webkit';
} else if (navigator.product === 'Gecko') {
return 'Moz';
} else {
return '';
}
}()),
Determines if the current browser supports touch.
@type {Boolean} True, if touch is enabled.
TOUCH_ENABLED: (function() {
var div = document.createElement('div');
div.setAttribute('ontouchstart', 'return');
return typeof div.ontouchstart === 'function';
}()),
Determines if the current browser is an iPhone with a retina display.
returns: {Boolean} True, if this display is a retina display
RETINA_DISPLAY: (function() {
if (navigator.userAgent.indexOf('iPhone') !== -1 && window.devicePixelRatio === 2) {
var viewport = document.querySelector('meta[name="viewport"]');
if (viewport == null) {
viewport = document.createElement('meta');
document.head.appendChild(viewport);
}
viewport.setAttribute('content', 'width=640');
return true;
} else {
return false;
}
}()),
Determines if for current browser Flash should be used to play
sound instead of the native audio class.
@type {Boolean} True, if flash should be used.
USE_FLASH_SOUND: (function() {
var ua = navigator.userAgent;
var vendor = navigator.vendor || "";
// non-local access, not on mobile mobile device, not on safari
return (location.href.indexOf('http') === 0 && ua.indexOf('Mobile') === -1 && vendor.indexOf('Apple') !== -1);
}()),
If click/touch event occure for these tags the setPreventDefault() method will not be called.
USE_DEFAULT_EVENT_TAGS: ['input', 'textarea', 'select', 'area'],
CANVAS_DRAWING_METHODS: [
'putImageData', 'drawImage', 'drawFocusRing', 'fill', 'stroke',
'clearRect', 'fillRect', 'strokeRect', 'fillText', 'strokeText'
],
Keybind Table.
You can use 'left', 'up', 'right', 'down', 'a', 'b' for preset event.
@example
enchant.ENV.KEY_BIND_TABLE = {
37: 'left',
38: 'up',
39: 'right',
40: 'down',
32: 'a', //-> use 'space' key as 'a button'
}
KEY_BIND_TABLE: {
37: 'left',
38: 'up',
39: 'right',
40: 'down'
},
PREVENT_DEFAULT_KEY_CODES: [37, 38, 39, 40, 32],
@type {Boolean}
SOUND_ENABLED_ON_MOBILE_SAFARI: false,
Determines if WebAudioAPI is enabled. (true: use WebAudioAPI instead of Audio element if possible)
USE_WEBAUDIO: (function(){
return location.protocol !== 'file:';
}()),
Determines if animation feature is enabled. (true: Timeline instance will be generated in new Node)
USE_ANIMATION: true
};
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.