How do I detect screen orientation for a square screen ?

  • Hi there,

    I am making a game for the Gear 2 Neo smartwatch. I would like the game to detect screen orientation in order to show the start menu when the watch is on landscape. The problem is that if I understand well the detection method for Construct 2, it's comparing screen width and lenght and getting an answer from that. That's not going to work for a 320x320 screen... neither is a simple change of scale as the scale is exactly the same in landscape and portrait. How would I do that ?

  • No answers ??

  • The Browser object has a "Is portrait/landscape" event.

  • blackhornet the "is portrait/landscape" thing typically fails on quadratic screens (for example on blackberry phones) for obvious reasons..

    McGuigew Does the smartwatch have a gyroscope? If so you could guess by its output which way the user is looking at it.

  • Hi there, the smartwatch does have a gyroscope (Gear 2 Neo) , can you tell me a little bit more?

  • With the gyroscope, you could try to compare the angle on all three axises and deduct the orientation.

    The is portrait/landscape will never work on a square screen since it is never portrait or landscape (portrait means the aspect ratio is inferior to 1, landscape means the aspect ratio is superior to 1, which is why on a tablet or mobile there are 2 positions landscape and 2 positions portrait.)

  • Thanks Aphrodite , can I do that in C2 ?

  • Use the Touch plugin and the search function of the forums.

  • Kyatric OK I'll try that, and sorry for the useless thread

  • OK guys. I did investigate and I find myself in a difficult situation because C2 movement coding doesn't work with the Gear 2, it uses other expressions to express for alpha, beta, and gamma. If someone can help and build a modified Touch object that would use the Gear 2's expressions, I think it could work.

    I found this page that explains very well how the Gear 2 works.

    http://denvycom.com/blog/accelerometer- ... ur-gear-2/

    Kyatric would you know how to do that? I'd be very grateful!

  • No one can help me code this?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The Touch plugin uses that same code to get the device orientation.

  • Hi ramones, thanks for replying to me!

    Well, I tried puting this very simple .capx into the watch (works perfect on the navigator with position emulator) and it just doesnt work... any idea? The tizen sdk doesnt change anything and I just do an export of my C2 game in HTML5...

  • Basically what I coded was : if alpha superior to 70 and inferior to 95, make a red square visible... this should work. Also, I have a text in the middle of the screen showing alpha, beta and, gamma, all emulated values show in the google emulator, nothing on the watch...

  • If anyone is still reading this: I have found that the c2runtime.js in html5 export by C2 contains the expression "screen.orientation.lock". It appears many times and I am really not a good coder so if anyone has an idea...

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)