我在Cordova应用程序中使用Phaser 3。我尝试在屏幕上显示图像。代码在浏览器版本中工作正常。因此,如果我运行:cordova run browser
,则所有内容均正确显示。
但是如果我运行cordova run ios
那么图像就不能正常显示。我也用Xcode打开了应用程序,没有看到任何相关的错误。
以下是相关章节:
function preload ()
{
console.log('preload.......')
this.load.image("emptytile", "./assets/sprites/emptytile.png");
// this.load.image("logo", "url(../img/logo.png)");
this.load.image("logo", "./assets/sprites/logo.png");
}
function create ()
{
this.add.image(200, 200, "emptytile");
this.add.image(30, 100, "logo");
const ThirtyConsonantsButton = this.add.text(100, 100, 'Thirty Consonants', { fill: '#0f0' })
ThirtyConsonantsButton.setInteractive();
ThirtyConsonantsButton.on('pointerdown', () => { console.log('pointerdown'); });
}
然后为了查看任何可能的错误,我通过Xcode打开应用程序,控制台调试区域显示以下内容:
2021-03-25 19:25:01.049522+0800 HelloCordova[23044:1549947] Apache Cordova native platform version 6.2.0 is starting.
2021-03-25 19:25:01.049690+0800 HelloCordova[23044:1549947] Multi-tasking -> Device: YES, App: YES
2021-03-25 19:25:01.058846+0800 HelloCordova[23044:1549947] Could not load the "LaunchStoryboard" image referenced from a nib in the bundle with identifier "io.cordova.hellocordova"
2021-03-25 19:25:01.291165+0800 HelloCordova[23044:1549947] The preference key "AllowNewWindows" is not defined and will default to "FALSE"
2021-03-25 19:25:01.292422+0800 HelloCordova[23044:1549947] The preference key "MediaPlaybackAllowsAirPlay" is not defined and will default to "TRUE"
2021-03-25 19:25:01.297305+0800 HelloCordova[23044:1549947] The preference key "AllowBackForwardNavigationGestures" is not defined and will default to "FALSE"
2021-03-25 19:25:01.297452+0800 HelloCordova[23044:1549947] The preference key "Allow3DTouchLinkPreview" is not defined and will default to "TRUE"
2021-03-25 19:25:01.297533+0800 HelloCordova[23044:1549947] CDVWebViewEngine will reload WKWebView if required on resume
2021-03-25 19:25:01.297660+0800 HelloCordova[23044:1549947] Using WKWebView
2021-03-25 19:25:01.298095+0800 HelloCordova[23044:1549947] [CDVTimer][console] 0.048995ms
2021-03-25 19:25:01.298296+0800 HelloCordova[23044:1549947] [CDVTimer][handleopenurl] 0.058055ms
2021-03-25 19:25:01.299815+0800 HelloCordova[23044:1549947] [CDVTimer][intentandnavigationfilter] 1.384974ms
2021-03-25 19:25:01.300050+0800 HelloCordova[23044:1549947] [CDVTimer][gesturehandler] 0.066042ms
2021-03-25 19:25:01.300178+0800 HelloCordova[23044:1549947] [CDVTimer][TotalPluginStartup] 2.219081ms
2021-03-25 19:25:01.442929+0800 HelloCordova[23044:1549947] WF: === Starting WebFilter logging for process HelloCordova
2021-03-25 19:25:01.443112+0800 HelloCordova[23044:1549947] WF: _userSettingsForUser : (null)
2021-03-25 19:25:01.443229+0800 HelloCordova[23044:1549947] WF: _WebFilterIsActive returning: NO
2021-03-25 19:25:02.073818+0800 HelloCordova[23044:1549947] The preference key "AutoHideSplashScreen" is not defined and will default to "TRUE"
2021-03-25 19:25:02.884798+0800 HelloCordova[23044:1549947] Running cordova-ios@6.2.0
2021-03-25 19:25:02.885008+0800 HelloCordova[23044:1549947] Phaser v3.53.1 (WebGL | Web Audio) https://phaser.io
2021-03-25 19:25:02.885198+0800 HelloCordova[23044:1549947] resizeGame
2021-03-25 19:25:02.970339+0800 HelloCordova[23044:1549947] preload.......
2条答案
按热度按时间pkmbmrz71#
这篇文章给出了答案:
Cordova iOS Cross origin requests are only supported for HTTP
希望这对以后的其他人有帮助。
gudnpqoy2#
如果您在以下版本中使用Cordova和Cordova-ios:
cordova 第11.0.0版。
cordova -ios第6.0.0版。
然后,您可以通过以下方式编辑config.xml文件:
您的图像,然后将被加载,而不需要额外的cordova插件。