Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is this game compatible for android #3

Open
RakeshShresthaNP opened this issue Sep 29, 2023 · 1 comment
Open

Is this game compatible for android #3

RakeshShresthaNP opened this issue Sep 29, 2023 · 1 comment

Comments

@RakeshShresthaNP
Copy link

Is this game compatible with android .. if ok for android also then how to move and take screen shot

@michaliskambi
Copy link
Member

I'll give a better answer later (~next week), a quick answer for now:

  1. In principle, the game should work on Android, it is cross-platform code.

    • The 3D models may be a bit heavy for cheaper devices, but then at worst case -> you will get low FPS. But the game should work.
  2. How to move? The ready solutions from https://forum.castle-engine.io/t/android-game-character-forward-and-backward-movements/914/2 should be good enough. I'll see about adding them to this example, it should be trivial to make it work.

  3. How to take a screenshot?

    • I see that the code of this game only watches for "F5" key press, so naturally it will never occur on mobile (well, we could handle external keyboard, but that's not a solution for normal users.) To make it work, you just have to add a button that exposes the same functionality. The button will be clickable.

    • As independent missing thing, right now this example uses Container.SaveScreenToDefaultFile which automatically guesses the best screenshot location. But on Android.. it actually just gives up. The SaveScreenPath function returns empty string, and then SaveScreenToDefaultFile does nothing.

    • A quick solution is to pass a screenshot location yourself. You can e.g. save files in ApplicationConfig('') directory. In other words, handling a button click like this:

      procedure TMyView.MyButtonClick(Sender: TObject);
      var
        ScreenShotUrl: String;
      begin
        ScreenShotUrl := FileNameAutoInc(ApplicationConfig(''), '_screen_%d.png');
        Container.SaveScreen(ScreenShotUrl);
        WritelnLog('Saved to ' + ScreenShotUrl);
      end;
    • The above will kind of work... but there's another problem, the directory ApplicationConfig('') is actually not readily visible for Android user. It is not something you will immediately see e.g. in Android Photos application. To send the screenshot to that location, one should use Android service ( https://castle-engine.io/android_services ) called "photo_service" ( https://github.com/castle-engine/castle-engine/blob/master/tools/build-tool/data/android/integrated-services/photo_service/README.adoc ).

Note that some of the above differences (like no keyboard on Android) are just necessary, i.e. Castle Game Engine (just like other engines) cannot 100% hide these platform differences from you. E.g. you need a button on mobile to make a screenshot, while on desktop handling keypress may be enough. We mentioned this in manual https://castle-engine.io/manual_cross_platform.php#section_input .

But still in CGE we want to give you easy ways to deal with these differences, and this particular example should demonstrate them. I think we can e.g. make screenshots more automatically send to Androd "photos" if developer uses SaveScreenToDefaultFile. I'll look into this and give better answer soon :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants