Jump to content


Photo

Full screen iPhone app with HTML5


  • Please log in to reply
8 replies to this topic

#1 2Dcube

2Dcube

    Programming sucks

  • GMC Member
  • 704 posts
  • Version:GM:Studio

Posted 30 September 2011 - 02:55 PM

What's great about Game Maker:HTML5 is that you can test some touch screen game ideas with it.
However to get it to run optimally there's some issues I ran into and I haven't seen a topic about those yet.

We know you can play a HTML5 game on your iPhone in its browser, but I wanted to make it full screen, just as if it's an app you could find in the app store. Here's how!

Step 1

Make a game / anything with a resolution of 320 x 480
Make sure it is controlled by mouse / tilt / not keyboard
Create the application

Step 2

Next we need to edit the index.html file, open it in a text editor.
We will change this line:

<meta name="apple-mobile-web-app-status-bar-style" content="default" />

Into this:

<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />


This will make the iPhone's top status bar half transparent so we can see all of the game.

Step 3

By default, the game will not fill the screen exactly, because there is a small margin around the canvas element.
We can change this by adding the following code somewhere between the <head> tags in the html:

<style type='text/css'>
div {position:absolute;left:0px;top:0px;width:100%;height:100%;}
</style>

Next put the canvas element between <div> tags, like so:

<div><canvas id="canvas" width="320" height="480">
<p>Your browser doesn't support HTML5 canvas.</p>
</canvas></div>

And finally right beneath that:

<script type="text/Javascript">
//get div to gain access to window size
div=document.getElementsByTagName('div')[0]
//set canvas size to the whole window
canvas=document.getElementsByTagName('canvas')[0]
canvas.width=div.scrollWidth
canvas.height=div.scrollHeight
</script>

This will make sure the game fits the screen exactly. (There's probably some other ways to do this as well).

Step 4

Put your files somewhere online.
Navigate to the URL on your iPhone.
Use the option "Add to home screen" in your iPhone's browser.

Done! You can start the app from your iPhone's home screen and in full screen!

Tip: You can also create an icon for your app, as described here (step 3).

----

Hope this is helpful. I just figured this out and haven't really actually tested many ideas with it but if I do I'll post a link.

Edited by 2Dcube, 30 September 2011 - 02:57 PM.

  • 0

#2 mazimadu

mazimadu

    GMC Member

  • GMC Member
  • 203 posts

Posted 30 September 2011 - 05:26 PM

I remember bringing this up in an earlier post. Into some mouse control issues when testing on my phone.

http://gmc.yoyogames...howtopic=520197

Thanks for the solution.

PS: Do you think a game of 960x640 would scale well on a phone browser? Just a thought since accommodation for tablets would be nice. :smile:
  • 0

#3

  • Guests

Posted 30 September 2011 - 05:46 PM

Scaling of ANY kind on iOS4 is terrible! It'll slow the HTML5 game down to a CRAWL!

#4 mazimadu

mazimadu

    GMC Member

  • GMC Member
  • 203 posts

Posted 30 September 2011 - 06:43 PM

Scaling of ANY kind on iOS4 is terrible! It'll slow the HTML5 game down to a CRAWL!

Then I guess the best thing to do is set the resolution for each device using the metadata then?
  • 0

#5 AJArmstron

AJArmstron

    GMC Member

  • GMC Member
  • 157 posts
  • Version:GM:HTML5

Posted 06 February 2012 - 02:13 PM

Hi - this is an interesting post. What about converting to an Android phone (as opposed to an iPhone?) For example. is it possible to change the meta tag:
<meta name="apple-mobile-web-app- status-bar-style" content="black-translucent" />
to android?
  • 0

#6 rucodemente

rucodemente

    GMC Member

  • GMC Member
  • 55 posts

Posted 22 February 2012 - 08:13 PM

¿Is there a way to check if the device is currently connected to the web? (I'm thinking iOS, that's why I'm asking here)

I want to use local storage to store some values in case the device is offline, but then I'd like to check if there's a connection available, to update the values if not, use the stored values... and such.

As far as I know there's no way to use local storage directly in GM as of today, I must create a javascript extension, ¿right?

Thanks
  • 0

#7 Mike.Dailly

Mike.Dailly

    Evil YoYo Games Employee

  • Administrators
  • 1482 posts
  • Version:GM:Studio

Posted 22 February 2012 - 11:30 PM

saving ini and text files go to local storage. When you try and load a file, it checks there first.
  • 0

#8 rucodemente

rucodemente

    GMC Member

  • GMC Member
  • 55 posts

Posted 22 February 2012 - 11:40 PM

saving ini and text files go to local storage. When you try and load a file, it checks there first.


Thanks, Mike!
  • 0

#9 rucodemente

rucodemente

    GMC Member

  • GMC Member
  • 55 posts

Posted 24 February 2012 - 12:14 AM

For some reason, the status bar keeps showing, and it looks like the canvas is being scaled or something, because the images look blurred.
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users