Jump to content

Phaser bugs on iPhone


royibernthal
 Share

Recommended Posts

I've followed the Full Screen Mobile project template (well, took some boot properties from it) and my game seems to be acting very weird on iPhone, while on desktop it runs perfectly.

 

First of all, often it just stops loading and nothing happens, I just see a white page.

Often even after loaded, some of the images are missing and I have to refresh the page to see them all.

 

When I'm loading audio the game doesn't even start (preloader is stuck on 100%).

 

The game doesn't fit into screen on load, only once I'm switiching between landscape <-> portrait.

Portrait seems to fit well into screen while landscape is not perfect.

 

When the game is being resized to fit into the screen, some of the objects coordinates become messed up, and the scale of the preloadSprite doesn't match the scaled game. (I've got an identical normal sprite below it and their scales are different)

 

Regardless of force orientation to landscape, the game can also be viewed in portrait, and the incorrectOrientation doesn't appear.

 

BootState relevant code:

 

BootState.prototype.preload = function(){game.load.image('preloader', 'images/preloader.jpg');game.load.image('incorrectOrientation', 'images/incorrectOrientation.png');};BootState.prototype.create = function(){game.stage.backgroundColor = 0xFFFFFF;game.input.maxPointers = 1;game.stage.disableVisibilityChange = true; //Disables pause when game loses focusgame.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;game.scale.pageAlignHorizontally = true;game.scale.pageAlignVertically = true;if (game.device.desktop){}else{game.scale.forceOrientation(true, false, 'incorrectOrientation');game.scale.hasResized.add(BootState.prototype.gameResized, this);game.scale.enterIncorrectOrientation.add(BootState.prototype.enterIncorrectOrientation, this);game.scale.leaveIncorrectOrientation.add(BootState.prototype.leaveIncorrectOrientation, this);game.scale.setScreenSize(true);}game.state.start('preloader');}BootState.prototype.gameResized = function(width, height){}BootState.prototype.enterIncorrectOrientation = function(){document.getElementById('orientation').style.display = 'block';}BootState.prototype.leaveIncorrectOrientation = function(){document.getElementById('orientation').style.display = 'none';}

 

PreloaderState relevant code:

var soundsLoaded = new Array();function loadSound(key, fileName){if (fileName == undefined) fileName = key;game.load.audio(key, ['sounds/' + fileName + '.mp3']);//, 'sounds/background.ogg']);soundsLoaded.push(key);}PreloaderState.prototype.preload = function(){this.preloaderBackground = game.add.sprite(0, 0, 'preloader');this.preloader = game.add.sprite(0, 0, 'preloader');this.preloaderBackground.alpha = 0.5;this.preloader.x = this.preloaderBackground.x = game.scale.width / 2 - this.preloader.width / 2;this.preloader.y = this.preloaderBackground.y = game.scale.height / 2 - this.preloader.height / 2;game.load.setPreloadSprite(this.preloader);game.load.image('illustration', 'images/illustration.jpg');preloadRibbon();preloadComponent();loadSound('background', music_background);loadSound('click');loadSound('openChest');};
Link to comment
Share on other sites

First of all, often it just stops loading and nothing happens, I just see a white page.

Often even after loaded, some of the images are missing and I have to refresh the page to see them all.

 

This is almost certainly to do with how you're testing / packaging your game. Do you concat all JS files into a single lib for testing? Or just have a whole bunch of script tags in your html and nothing controlling their load order?

 

When I'm loading audio the game doesn't even start (preloader is stuck on 100%).

 

 

You're likely using an mp3 bit rate iOS doesn't support.

 

When the game is being resized to fit into the screen, some of the objects coordinates become messed up, and the scale of the preloadSprite doesn't match the scaled game. (I've got an identical normal sprite below it and their scales are different)

 

 

Object coordinates and scales are never changed as a result of scaling, ever. There literally isn't a single line of code in Phaser that does this. My guess would be you've scaled your sprite based on a value derived from the scaled game size or similar, which has since changed.

Link to comment
Share on other sites

I have a whole bunch of script tags in my html, I didn't know it wasn't okay.

 

Edit: I had all of the js files concat and minified into one js file via http://jscompress.com/, and the problems persist.

 

Is there some comfortable way to concat the files or do I just go over them by one by and copy paste?

 

 

Will having an ogg version of the sound solve the problem or will I have to take a more through look at bitrates?

 

I centered the preload sprite according to game.scale width and height, but I didn't scale anything.

 

 

Is it normal for code built with Phaser to have an average 30 out of 60 fps on mobile? Is it the framework or am I doing something wrong? (I understood that with some effort one can hit 60 fps)

Link to comment
Share on other sites

I have a whole bunch of script tags in my html, I didn't know it wasn't okay.

 

Edit: I had all of the js files concat and minified into one js file via http://jscompress.com/, and the problems persist.

 

Is there some comfortable way to concat the files or do I just go over them by one by and copy paste?

 

I use uglifyjs, you'll need npm to install it. Works well for me, just make sure to pass the javascript files in the same order they are in the html file.

 

 

Will having an ogg version of the sound solve the problem or will I have to take a more through look at bitrates?

 

If I'm not wrong, Safari doesn't support .ogg file format.

Link to comment
Share on other sites

  • 2 weeks later...

This is almost certainly to do with how you're testing / packaging your game. Do you concat all JS files into a single lib for testing? Or just have a whole bunch of script tags in your html and nothing controlling their load order?

 

 

You're likely using an mp3 bit rate iOS doesn't support.

 

 

Object coordinates and scales are never changed as a result of scaling, ever. There literally isn't a single line of code in Phaser that does this. My guess would be you've scaled your sprite based on a value derived from the scaled game size or similar, which has since changed.

 

Have the same problem with sound i my iPhone 4 what bitrate should I use?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...