Porting your web game to Tizen

20

Transcript of Porting your web game to Tizen

Page 1: Porting your web game to Tizen
Page 2: Porting your web game to Tizen

7 Years Console Engine Programmer.

3 Years Mobile R&D Technical Lead.

Founder & CEO of Playir.

Page 3: Porting your web game to Tizen

http://player.com

Page 4: Porting your web game to Tizen

<access origin="*"></access>

<tizen:privilegename="http://tizen.org/privilege/application.launch"/>

<tizen:privilege name="http://tizen.org/privilege/filesystem.read"/>

<tizen:privilege name="http://tizen.org/privilege/unlimitedstorage"/>

Page 5: Porting your web game to Tizen

window.onload = function(){

CC.GetScreenSize( function(screenWidth, screenHeight, pixelDensity) {

var scaling = 1.0 / pixelDensity;var viewport = document.querySelector(

'meta[name=viewport]' );viewport.setAttribute( 'content', 'width=device-width, initial-

scale=' + scaling + ', maximum-scale=' + scaling +', user-scalable=0' );

GetPackagedFiles( function () {new CCEngine();

});});

};

Page 6: Porting your web game to Tizen

ln -s source target

mklink /d “target" “source"

Page 7: Porting your web game to Tizen

if( window.tizen && window.tizen.systeminfo ) {var SuccessCallback = function(display) {

callback( display.resolutionHeight, display.resolutionWidth, display.resolutionHeight/width );

};var ErrorCallback = function(error) {

//alert( error );callback( 800, 400, 1.0 );

};window.tizen.systeminfo.getPropertyValue( "DISPLAY",

SuccessCallback, ErrorCallback );}

Page 8: Porting your web game to Tizen

var scaling = 1.0 / pixelDensity;var viewport = document.querySelector( 'meta[name=viewport]' );viewport.setAttribute( 'content', 'width=device-width, initial-scale=' + scaling + ', maximum-scale=' + scaling +', user-scalable=0' );

Page 9: Porting your web game to Tizen

config.xmlhwkey-event="enable“

document.addEventListener( 'tizenhwkey', function(e) {if( e.keyName == "back" ) {

if( gEngine.handleBackButton() ) {}else {

tizen.application.getCurrentApplication().exit();}

}else if( e.KeyName === "menu" ) {}

});

Page 10: Porting your web game to Tizen

tizen.filesystem.resolve( 'wgt-package/packaged',function(dir){

documentsDir = dir;dir.listFiles( onsuccess, onerror );

},function(e){

onerror( e );},"r"

);

Page 11: Porting your web game to Tizen

function onsuccess(files) {CCEngine.PackagedFiles = [];for( var i=0; i<files.length; ++i ){

var filename = files[i].name;CCEngine.PackagedFiles.push( filename );if( filename === "appinfo.json" ) {

var url = "packaged/" + files[i].name;var xhr = new XMLHttpRequest();

…}

}callback();

}

Page 12: Porting your web game to Tizen

var appControl = new tizen.ApplicationControl( "http://tizen.org/appcontrol/operation/view", url );tizen.application.launchAppControl( appControl, null,

function() {},function(e) {} );

Page 13: Porting your web game to Tizen

var appControl = new tizen.ApplicationControl( "http://tizen.org/appcontrol/operation/view", url );tizen.application.launchAppControl( appControl, null,

function() {},function(e) {} );

window.open(…)

Page 14: Porting your web game to Tizen

if( !String.Contains( url, "facebook.com/recover/initiate/" ) && !String.Contains( url, "facebook.com/login/identify?" ) ) {

var allowedURLs = [ "about:blank", "login.php?",…];for( var i=0; i<allowedURLs.length; ++i ) {

if( String.Contains( url, allowedURLs[i] ) ) {return;

}}

}CCAPIFacebook.FinishLogin();// "only login function is available”

Page 15: Porting your web game to Tizen
Page 16: Porting your web game to Tizen
Page 17: Porting your web game to Tizen
Page 18: Porting your web game to Tizen
Page 19: Porting your web game to Tizen
Page 20: Porting your web game to Tizen