I am using Phaser 3 inside a Cordova App.
I am trying to display an image on the screen.
The code works properly in the browser version.
Therefore if I run: cordova run browser
then everything displays properly.
But if I run cordova run ios
then the images do not appear properly.
I have opened the app using Xcode too and I don’t see any relevant errors to it.
Here is the relevant section:
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'); });
}
And then in order to see any possible errors I open the app thru Xcode and the console debug area shows the following:
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 [email protected]
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
Answers
This post had the answer:
Cordova iOS Cross origin requests are only supported for HTTP
Hope this helps other people in the future....
If you are using Cordova and Cordova-ios in following versions:
Then you can edit your config.xml file in following way:
Your images then will be loaded without need for additional cordova plugins.