Comments (7)
@luanpotter any thoughts on this?
from flame.
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.
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.
@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.
Hey @paulpmi did @luanpotter advice fixed your problem?
from flame.
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.
No problem, thanks for the feedback
from flame.
Related Issues (20)
- Rays outside a CircleHitbox are seen by RaycastResult as inside. HOT 3
- Keyboard not working when resizing the web HOT 5
- Support dynamic changes to the layer opacity on tiled maps
- Tilemaps error occuring on Chrome mobile HOT 2
- ZigZagController with ColorEffect causes an exception HOT 4
- TextBoxComponent with typer text shows pink image before rendering text HOT 5
- SpriteWidget has unused parameters HOT 1
- Anchor is invalid when transform by matrix4 ?
- Klondike Tutorial, Step 5: Add code and further explanation of FlatButton and others, or at least a link to its code #19 HOT 6
- Strange phenomenon in flame rendering text HOT 7
- Convert ClipComponent factory Constructor to redirecting Constructor. HOT 1
- Unable scroll the text of the ScrollTextBoxComponent if I do not use timePerChar HOT 1
- Can not find asset when Flame Game is used as a module or package HOT 8
- texture packer can't override images HOT 6
- I'd like to call the child onRemove. HOT 4
- Add onComplete callback to ScrollTextBoxComponent HOT 2
- Flame + Forge2D + Riverpod == broken? HOT 1
- Change `Forge2DGame`'s `cameraComponent` constructor parameter to `camera` for consistency with `FlameGame`
- Not compatible contact type HOT 1
- Unverified Breakpoint in VSCode. DebugService: Error serving requestsError: FormatException: Unsupported URI form. HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flame.