Why does my p5js game not work for iPhones?


#1

I made a little game in p5js and can’t figure out why it won’t work for iPhones. For all I know p5js doesn’t work at all with iPhones though so if that’s the case let me know. The game seems to work fine on PC’s and Android phones.

Unfortunately I can’t do much testing for iPhones either as I only have an old iPhone 4 which can’t run much modern stuff or I can call my Mom and have her try to open the page on her phone, but that hasn’t shown to be particularly helpful…

The game can be played at:
https://mikenotintheflesh.github.io/SkiGame

The code is at:

Thanks for any insight to getting it working for ios (if possible).

edit: eliminated a double negative in first paragraph


#2

can you get a console output while running it on your iphone4?


#3

Can you get something simpler working? Display a simple hard-coded shape. Then add a small amount of code until you understand what’s causing the problem. Then try to narrow the problem down to a MCVE so we can help you debug.


#4

So I got everything to display on my iPhone 4 by eliminating two js bugs.

First I had a couple functions which I set a default value for the parameters. Apparently this is a no-no in js but Android and PC let it slide. If you use default params in js they have to be of the ‘null / false’ variety.

Second, I used a few for loops of the following variety:

for (let card of cards) {
    card.x++;
}

These didn’t work and I switched them to:

for (var i = 0; i < cards.length - 1; i++) {
    cards[i].x++
}

I figure this is an iPhone4 thing cause it’s old and that is a newish for loop.

This got everything to at least display, but not to start the game. I’m using ‘weinre’ to get a console output from the phone (but it’s not outputting what I’d expect it to, like: console.log(“hello world”);, or error messages ).

My function “function mouseClicked() {do stuff}” doesn’t seem to do anything. It’s supposed to start the “loop()”. However something sends the message “start ios!” to my console whenever the screen is touched.

My googlefu has been unable to decode the meaning of this message (“start ios!”). It’s probably incredibly simple. Does anyone know what it means? Btw: this is the only console msg my phone has sent over ‘weinre’, and I don’t know why :frowning:

Through the ‘weinre’ console on my PC I can send the “loop()” command to the phone and the game will start up. “mousePressed()” seems to work to move the character around although the iPhone4 runs it very slowly…

Maybe tomorrow I’ll migrate the “mouseClicked()” commands to “mousePressed()”. I tried a quick solution tonight, but it was unfruitful.

Any feedback is appreciated.

Anyone know what this “start ios!” console output is about? Lastly Chrome doesn’t output that message to my console. Only Safari.


#5

This has nothing to do w/ the iPhone version ‘x’ or any other OS at all! :face_with_raised_eyebrow:
We should blame the browser running the app instead! :face_vomiting:

Either install an actual modern browser in your own OS or convert your modern JS code to the jurassic ES5 version of it: :japanese_goblin:


#6

@GoToLoop To be honest, your comment was a rude way to assist someone. you could have offered this advice in a more respectful tone. Please be more Courteous in the future.


#7

Unable to update the ios beyond version 7, so browser updates aren’t available either.

Good to know the problem is with new js on old software though.


#8




#9

All those browsers require iOS 9. My iPhone 4 maxes out at iOS 7. They won’t install…