Jump to content


Photo

Questions regarding mobile devices


  • Please log in to reply
23 replies to this topic

#1 Chronic

Chronic

    Administrator

  • Global Moderators
  • 2729 posts
  • Version:GM:Studio

Posted 13 January 2012 - 07:51 AM

Because of the varying sizes of mobile devices (i'm mainly interested in iOS as of now), what is the recommended way to making a game run at a devices native size?

Are there currently any functions to lock the screen orientation, and get gyroscope data?
  • 0

#2

  • Guests

Posted 13 January 2012 - 12:12 PM

There's 2 or 3 ways of doing this.

  • Pick a size (1024x768) and then allow it to "scale to fit", which is the default. This is fine for most things, but on lower res devices, can look a bit pooh.
  • Have a couple of room sizes and "pick" the best one for your device screen size.
  • We're adding cross platform support for browser_width and browser_height (not the best of names...) so that on non-desktop, you'll be able to see the sizes of the screens and resize your view to fit.

There isn't anything usable yet for device locking, although the runner can do it. It was all done from scripts in the past.

Yes, you will be able to use YoYo_GetTiltX(), YoYo_GetTiltY() and YoYo_GetTiltZ(), but these have been doing using extensions and we haven't gotten them into the main code base yet. We'll try and get them soon.

#3 Sindarin

Sindarin

    Indie Game Developer

  • New Member
  • 1644 posts
  • Version:GM:HTML5

Posted 21 January 2012 - 05:43 AM

Instead of browser_width and browser_height, wouldn't display_get _width() and display_get_height() functions sound more semantic?

About orientation, I suppose it would be useful to have a "Device Orientation" (Landscape,Portrait) setting and a "Enable Auto Orientation" in the Global Game Settings, under Android and iPhone.
It'd be also nice to have a YoYo_GetOrientation() GML function ( returns 0 on landscape, 1 on portrait )

Edited by Sindarin, 21 January 2012 - 05:44 AM.

  • 0

#4

  • Guests

Posted 21 January 2012 - 09:50 PM

I've added display_get_orientation() for our Solitaire game, so that should be there next version.

I know browser_width/browser_height aren't great names, but it does make it code compatible with the HTML5 version.

#5 Chronic

Chronic

    Administrator

  • Global Moderators
  • 2729 posts
  • Version:GM:Studio

Posted 21 January 2012 - 10:32 PM

Will there be also a display_set_orientation(portrait/landscape/free)? (but with better sounding arguments)
  • 0

#6 Sindarin

Sindarin

    Indie Game Developer

  • New Member
  • 1644 posts
  • Version:GM:HTML5

Posted 22 January 2012 - 12:22 AM

I know browser_width/browser_height aren't great names, but it does make it code compatible with the HTML5 version.


I personally would give priority to the desktop platforms for consistency and also since you named the orientation function display_get_orientation().
I believe desktop & mobile should come first then HTML5 as it needs a "browser" to work.

I would expect to do something like this:


if (os_browser == browser_not_a_browser)
{
    //for desktop and mobile
    return display_get_width();
}
else
{
    //for browsers
    return browser_width;
}


Anyway, as long as display_get_width() / display_get_height() work on mobile the same way as well, I will be happy actually. :D

And finally, do you have any plans to categorize all the internal YoYo functions at some point?
For example YoYo_GetTiltX() could be device_get_tilt_x(), YoYo_GetURL() could be web_open_url() or something.
I am just saying camelCase syntax looks a little out of place to people who use GML, and personally I always loved how the GML functions were neatly organized in categories d3d_ sprite_ sound_ etc.. :)

Edited by Sindarin, 22 January 2012 - 12:30 AM.

  • 0

#7

  • Guests

Posted 22 January 2012 - 09:52 AM

No, you can't set orientation, as thats automatically set by the phone/tablet. However, we will allow you to pre-select which orientations you want a game to follow, allowing you to force a landscape game etc.

I doubt we'll get the time to set new mirror functions for all the YoYo_???() ones, so they'll stay YoYo_???.

Allowing browser_width etc. on devices avoids the need for code like you posted - which is the point. It makes it simpler with less ifs and buts in your code, making it cleaner.

I'm not sure what display_get_width() etc. maps to on mobile, but the browser_width/height returns the physical pixels of the display.

#8 Sindarin

Sindarin

    Indie Game Developer

  • New Member
  • 1644 posts
  • Version:GM:HTML5

Posted 23 January 2012 - 08:45 PM

Okay, I know I am probably nitpicking again, but shouldn't the browser_width / browser_height be
browser_get_width() and browser_get_height() like window_get_width(), display_get_width() etc. and since they are not constants?

EDIT: Also just had this idea that the YoYo_GetURL(); could be renamed to browser_get_url() or browser_open_url() and this way you can build a relevant index of browser_* functions and categorize some YoYo ones under it :)

Edited by Sindarin, 23 January 2012 - 08:48 PM.

  • 0

#9

  • Guests

Posted 23 January 2012 - 11:11 PM

They are more like built in variables, I'm not a fan of functions to return simple variables, it's kind of like C++ accessors, which I think clutters up the code, and makes it look pretty ugly.

As to moving YoYo_????() to better function names. I wouldn't move them, but mirror them, and that is on my to-do list. We need the original names for compatibly purposes.

#10 Sindarin

Sindarin

    Indie Game Developer

  • New Member
  • 1644 posts
  • Version:GM:HTML5

Posted 24 January 2012 - 04:02 AM

Ah I can see what you mean, also noticed there are readonly variables like room_width & view_width, so it's not completely out of place. :)
  • 0

#11 Rossay

Rossay

    GMC Member

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

Posted 29 February 2012 - 02:56 PM

There's 2 or 3 ways of doing this.

  • Pick a size (1024x768) and then allow it to "scale to fit", which is the default. This is fine for most things, but on lower res devices, can look a bit pooh.
  • Have a couple of room sizes and "pick" the best one for your device screen size.
  • We're adding cross platform support for browser_width and browser_height (not the best of names...) so that on non-desktop, you'll be able to see the sizes of the screens and resize your view to fit.


This is probably a really stupid question, but what about if you were making games which primarily use pixel art? Wouldn't scaling etc. tend to make them blurry & defeat the point of using pixel art (which kind of needs a 1:1 or 1:2 ratio)?
  • 0

#12 Crystal Noir

Crystal Noir

    GMC Member

  • GMC Member
  • 88 posts

Posted 29 February 2012 - 02:59 PM

Hey guys :)

I asked myself this question about the screen size of an Android device. But I'm a little confused about this. I don't know with GM Studio how to design my test game and in witch room size and project resolution I have to choose.

The fact is that android devices have their resolution and that's not the same each time. So I try to understand how can I deal with GM Studio to make the game playable on several android devices.

Have you got an example or something ? I've seen the posts at the top of this topic but I'm just a little lost with this things :)

Thank you in advance :)
  • 0

#13 Chronic

Chronic

    Administrator

  • Global Moderators
  • 2729 posts
  • Version:GM:Studio

Posted 29 February 2012 - 03:10 PM

You can get the devices resolution using os_browser_width and os_browser_height
  • 0

#14 rwkay

rwkay

    YoYo Games CTO

  • YoYo Games Staff
  • 1979 posts
  • Version:Unknown

Posted 29 February 2012 - 03:14 PM

The tactic we use internally is to have a dummy initial room that modifies the width and height of the other rooms based on os_browser_width and os_browser_height (NOTE : These names will be changed in the future to be more intuitive). This allows you to adapt the rooms to fit what you are doing.

The other way that we have done is to just allow the room to stretch to fit and use iPhone resolution 960x480 (for landscape) and 480x960 (for portrait) and live with any issues on different devices, most folk are actually fine with that.

Russell
  • 0

#15 Crystal Noir

Crystal Noir

    GMC Member

  • GMC Member
  • 88 posts

Posted 29 February 2012 - 03:30 PM

The tactic we use internally is to have a dummy initial room that modifies the width and height of the other rooms based on os_browser_width and os_browser_height (NOTE : These names will be changed in the future to be more intuitive). This allows you to adapt the rooms to fit what you are doing.

The other way that we have done is to just allow the room to stretch to fit and use iPhone resolution 960x480 (for landscape) and 480x960 (for portrait) and live with any issues on different devices, most folk are actually fine with that.

Russell


The problem is , if you change the size room dynamically with a dummy , you have to modify sprites position and so on to make the game matches with the new resolution no ? The problem with resizing is that sprite are stretched or something...depend of the device (I work with Android and not iphone so, each phone has his resolution...).


PS : sorry for my english, I try to give my better to make you understand me ^^
  • 0

#16 rwkay

rwkay

    YoYo Games CTO

  • YoYo Games Staff
  • 1979 posts
  • Version:Unknown

Posted 29 February 2012 - 03:34 PM

Agreed on the changing sprite positions - you need to design your game around the strategy that you want.

i.e. if you are scrolling level based game then just increase the view width and height so larger screens can see more (rather than moving them around).

If you are a static game then scale the sprites or use relative positions..

You need to design within the limitations of the devices...

Our advice on Android - pick a resolution or 2 and scale on the other devices.

BTW - all input positions are scaled relative to the room so you do not need to keep changing the scale based on the device size, that is all done for you.

Russell
  • 0

#17 Crystal Noir

Crystal Noir

    GMC Member

  • GMC Member
  • 88 posts

Posted 29 February 2012 - 03:48 PM

Agreed on the changing sprite positions - you need to design your game around the strategy that you want.

i.e. if you are scrolling level based game then just increase the view width and height so larger screens can see more (rather than moving them around).

If you are a static game then scale the sprites or use relative positions..

You need to design within the limitations of the devices...

Our advice on Android - pick a resolution or 2 and scale on the other devices.

BTW - all input positions are scaled relative to the room so you do not need to keep changing the scale based on the device size, that is all done for you.

Russell


It's a little tricky for me (because of my english), do you have a small sample of your idea (with the dummy initial room) ? We should search the most resolution we find on android to know how to deal with that. For the input positions, if I understand, when we scale the room the sprite position will be correct automatically.

EDIT : I've found this : http://developer.and...ns_support.html

On the table at the bottom of this page, we can see the resolution screen android has. Phones are in the small and normal screen range.

Edited by Crystal Noir, 29 February 2012 - 03:57 PM.

  • 0

#18 daz

daz

    GMC Member

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

Posted 29 February 2012 - 06:02 PM

The good news is browser_width and height change based on the orientation, so that can be used to detect orientation changes.
  • 0

#19 King Tetiro

King Tetiro

    King of Orenna

  • GMC Member
  • 2394 posts
  • Version:GM8

Posted 29 February 2012 - 06:05 PM

The good news is browser_width and height change based on the orientation, so that can be used to detect orientation changes.


Question as I don't have GMS yet. Does the runner automatically switch the orientation based on the tilting? As I noticed on iPhones the interface can rotate.
  • 0

#20 Crystal Noir

Crystal Noir

    GMC Member

  • GMC Member
  • 88 posts

Posted 29 February 2012 - 07:24 PM

orientation doesn't work yet in GM Studio....there's a few bug with it for now. In fact, when the game launches it detects the orientation but does not rotate the screen.

Just a question : I have some difficulties to understand this sentence :

"BTW - all input positions are scaled relative to the room so you do not need to keep changing the scale based on the device size, that is all done for you."


That's because of my english....may be could you help me to understand this easier ?

Thank's in advance :)

Edited by Crystal Noir, 29 February 2012 - 08:36 PM.

  • 0

#21 daz

daz

    GMC Member

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

Posted 29 February 2012 - 08:43 PM

It appears to rotate the screen correctly for me on my Android 2.2.1 device when the orientation changes.
  • 0

#22 Crystal Noir

Crystal Noir

    GMC Member

  • GMC Member
  • 88 posts

Posted 29 February 2012 - 09:05 PM

It appears to rotate the screen correctly for me on my Android 2.2.1 device when the orientation changes.


with me, when the orientation changes, the game is streched but the game doesn't "rotate". Seems that the game doesn't rotate but is "compressed" by the new resolution.
  • 0

#23 King Tetiro

King Tetiro

    King of Orenna

  • GMC Member
  • 2394 posts
  • Version:GM8

Posted 29 February 2012 - 09:08 PM


It appears to rotate the screen correctly for me on my Android 2.2.1 device when the orientation changes.


with me, when the orientation changes, the game is streched but the game doesn't "rotate". Seems that the game doesn't rotate but is "compressed" by the new resolution.


I hope there's a way to fix the orientation so it doesn't rotate.
  • 0

#24 scurvycapn

scurvycapn

    GMC Member

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

Posted 29 February 2012 - 09:29 PM

I've been testing on my Galaxy Nexus and OG Droid and it seems that it is scaling everything down even when I set my room size to the native resolution of the device I am testing. This is resulting in some blurry graphics.

I set my room size to 720x1184 (Galaxy Nexus has a resolution of 720x1280 in portrait, 96 pixels used by the touchscreen buttons leaving 1184 usable). When I launch it, I notice "onSurfaceChanged :: width=360, height = 592" being spit out in the command prompt.

592 / 360 = 1.644~
1184 / 720 = 1.644~

It looks like it is halving the resolution (but keeping the same ratio). I've tried setting the room size to the resolution of my OG Droid (480x854) and testing on it and it does a similar thing. Surface set to 320 x 569 which is just slightly off the aspect ratio of the native resolution. I tried running that size of a room on the Galaxy Nexus and it used the same 360x592 surface it used for my 720x1184 room.

Any idea what would be causing that? I've tried Fixed Scale, Keep Aspect Ratio, and Full Scale under the graphics tab of the global game settings (not sure that even would have any effect on an Android app though) and always the same results.

Update: If I run a project on my tablet, it runs at the native resolution. This was a lower res project though, so it ended up scaling up to fit, but it displayed the proper resolution in the debug window for the surface size.

Edited by scurvycapn, 29 February 2012 - 11:14 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users