我如何包装我的enchant.js游戏在phonegap(apache cordova)? [英] How do I wrap my enchant.js game in phonegap (apache cordova)?

查看:138
本文介绍了我如何包装我的enchant.js游戏在phonegap(apache cordova)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的附魔游戏开始于

enchant();
window.onload = function() {
  game = new Game(...);
  game.onload = function() {...};
  game.start();
}

我在cordova / phonegap设置中将这些行放在哪里?

Where do I put these lines in the cordova/phonegap setup?

推荐答案

您需要在执行游戏/应用程序之前等待 deviceready / p>

You need to wait the deviceready event before executing your game/app:

function onLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);
}

function onDeviceReady() {
    enchant();
    window.onload = function() {
    game = new Game(...);
    game.onload = function() {...};
    game.start();
}

请参阅文档了解有关Cordova事件的更多详细信息。

See the documentation for more details about Cordova events.

这篇关于我如何包装我的enchant.js游戏在phonegap(apache cordova)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆