Manage save file on Android an PC #1993
Replies: 2 comments
-
I'm not familiar with mobile APIs but I'd define a Go interface like this, expose it, and add an implementation in Java and Objective-C.
|
Beta Was this translation helpful? Give feedback.
-
I figured out a work around for android. The fundamental problem is that android apps run from the You could just hard-code that path, but what I did is create a binding function that accepts a string which I can call from the Fwiw, here's a chat I had that helped me figure out a workflow. It starts with intercepting the back button and it ultimately reaches a slightly different approach in which I'm just passing the config json blob to java which handles the saving. my final binding file: package mob
import (
"github.com/charmbracelet/log"
"github.com/hajimehoshi/ebiten/v2"
"github.com/hajimehoshi/ebiten/v2/mobile"
"github.com/kendfss/shunt/gui"
)
var game ebiten.Game
func init() {
game = gui.NewGame()
mobile.SetGame(game)
}
func Dummy() {}
func OnBack() bool {
return game.(*gui.App).OnBack()
}
func ConfDir(s string) {
log.Info("setting conf dir", "path", s)
game.(*gui.App).Conf.Dir(s)
game.(*gui.App).Conf.Load()
} my main activity: package io.github.kendfss.shunt;
import android.os.Bundle;
import go.Seq;
public class MainActivity extends android.app.Activity {
private EbitenViewWithErrorHandling view;
@Override
protected void onCreate(Bundle savedInstanceState) {
io.github.kendfss.shunt.mob.Mob.confDir(this.getFilesDir().getPath());
super.onCreate(savedInstanceState);
Seq.setContext(getApplicationContext());
view = new EbitenViewWithErrorHandling(this);
setContentView(view);
}
@Override
protected void onPause() {
super.onPause();
if (view!=null) {
view.suspendGame();
}
}
@Override
protected void onResume() {
super.onResume();
if (view!=null) {
view.resumeGame();
}
}
@Override
public void onBackPressed() {
if (io.github.kendfss.shunt.mob.Mob.onBack()) {
super.onBackPressed();
}
}
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I was trying to create a file in order to save some game progress, various settings, etc...
Can someone suggest me some strategy/library in order to manage a save file on android and pc?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions