Code Monkey home page Code Monkey logo

Comments (7)

erickzanardo avatar erickzanardo commented on May 8, 2024

@luanpotter any thoughts on this?

from flame.

luanpotter avatar luanpotter commented on May 8, 2024

How are you handling your Game class and your PathSprite class? Can you share some more code on those bits? Basically if you are saving your data in a class that's going to get disposed when the user minimizes the app, it will be lost afterward. You can add it to the static context or inside a class that is going to be resilient towards that. However, if the user really closes (kills) your app, all runtime information is lost. The the only way to keep track of it using things like shared_preferences or sqlite.

from flame.

paulpmi avatar paulpmi commented on May 8, 2024

Hi sorry for the late reply

@override
void initState() {
    super.initState();

   _getGameStart();
 }
_getGameStart() async {

      Flame.audio.disableLog();
      Flame.audio.loadAll(['Calm.mp3']);
      Flame.images.loadAll(['star.png', 'starGlow.png', 'starCalm.png', 'path.png', 'starTrial.png']);

      var dimensions = await Flame.util.initialDimensions();
      gameController = new GameController( dimensions );

      gameWrapper = new GameWrapper( gameController );

  }
  GameController(this.dimenstions){
           initialize();
          _createStars();
         _initializeDragController();
   }

  void _initializeDragController() {
      PanGestureRecognizer gestureDetector = new PanGestureRecognizer( );

      Flame.util.addGestureRecognizer(
          gestureDetector
              ..onUpdate = (startDetails) => dragInput(startDetails.globalPosition));

      Flame.util.addGestureRecognizer(gestureDetector
            ..onEnd = (DragEndDetails d) => onUp());
  }

`

The PathSprite beside its initializer as a square with super.square there are no other functionalities

from flame.

luanpotter avatar luanpotter commented on May 8, 2024

@paulpmi , I'm assuming your GameWrapper is your implementation of the Game/BaseGame class. If you are saving that as a field of another component, it might get disposed, and then the constructor would be called again. I'd suggest creating a static variable to hold your instance, and only instantiate it once, as for the game state not to get lost. I'd suggest to add some logs in the constructor, where the points are all clear, and I suspect you shall find that it's being called again, because flutter disposes the widget tree when the app is minimized, including your game and the data. Saving it to a static context variable and making sure to instantiate it only once shall fix that problem :)

from flame.

erickzanardo avatar erickzanardo commented on May 8, 2024

Hey @paulpmi did @luanpotter advice fixed your problem?

from flame.

paulpmi avatar paulpmi commented on May 8, 2024

Busy month, sorry. Yes making the class that extends the BaseGame, in my case the Controller which is not shown, static fixes this problem. Thank you, I would have never thought of this !

from flame.

erickzanardo avatar erickzanardo commented on May 8, 2024

No problem, thanks for the feedback

from flame.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.