Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Android troubles  (Read 1502 times)

0 Members and 1 Guest are viewing this topic.

Gaz

  • Newbie
  • *
  • Posts: 3
    • View Profile
Android troubles
« on: January 25, 2018, 02:52:53 am »
So I managed to build the Android SFML libs, and got the example to work. Afterwards I tried to compile my own project, a small memory card game, and to my surprise everything went suprisingly smooth except for a few necessary changes that were easily fixed. Didn't expect it for an experimental build to actually work so well!

However I did find just one small problem (apart from the minimizing/maximizing thing) , and as I don't know anything about java I'm not sure if it's because my layout may be set up wrongly or is it due to SFML in some way. Here are some pictures:



Over here the view looks like it's fullscreen, but it's actually fullscreen and zoomed in/stretched, as my card clickboxes are left of the cards and not on the cards themselves, the first clickbox is just a few pixes switched to the left, while the last card in the row has a clickbox that's shifted left by more than half a card.

Sometimes, when I minimize then open the game again(I recreate the window on sf::Event::MouseEntered) I get this:



The cards are now in their proper position and the clickboxes are also where they're supposed to be, even though there's an ugly black bar below the game it's functional now.

Now I'd like to know if anyone knows the reason behind this and if it can be fixed?

The game works on all other platforms(any resolution) properly

Best,

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Android troubles
« Reply #1 on: January 25, 2018, 08:30:12 am »
The black bar looks exactly like the size of a on screen button drawer (for back, home and app switcher). Maybe SFML isn't taking that "optional" into consideration.

A fix for clicking in the wrong place would be to transform the "mouse" position to world coordinates by using the mapPixelToCoords function on the window.

As for a proper fix, one would have to investigate the issue further.

What minor changes did you have to apply to make SFML work for Android?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Gaz

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Android troubles
« Reply #2 on: January 25, 2018, 11:05:24 am »
To get my program fully running on android I had to replace the ifstream file handlers with the sf version of loading files, they worked right out of the box and I had no problems reading a text file.

About the clickbox issue, it's resolved now thanks to you, everything is working now as intended!

Thank you so much Expl0it3r!

Best,
Gaz

Gaz

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Android troubles
« Reply #3 on: January 25, 2018, 11:32:59 am »
Yes it does seem like when you use sf::RenderWindow::create() that it doesn't take into account the bottom part of the screen.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Android troubles
« Reply #4 on: January 25, 2018, 11:46:28 am »
Would be great if you could open a GitHub issue with details regarding your setup (IDE, NDK, Android device/simulator) and the problem description (maybe even repost the images). That way the issue isn't lost.

If you can't create an issue on GitHub, let me know and provide the setup details, so I can do it.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/