2048 Game in Flutter

518 views
Skip to first unread message

Ted Liao

unread,
Apr 13, 2018, 8:41:36 AM4/13/18
to Flutter Dev
I'v written and published a 2048 game in Flutter.  Just search for " 2048 Tile Puzzle Game" in both of the stores.  As far as I know, it's the first 2048 game written in Flutter.

https://itunes.apple.com/us/app/2048-tile-puzzle-game/id1369565637?ls=1&mt=8


If you don't already know, 2048 is a 2D Tile game.  

I did this to prove to myself that Flutter is performant in an animation rich environment, as it's in most top-quality mobile apps.  I started with standard Flutter animation widgets but very quickly found out that it can't handle the repeated and simultaneous tile movements the game requires.  By "handling", I mean perfectly smooth and fast animation frames and instant response to touch inputs. I would see lots of jerky motions and lag. So I turned to using the spriteWidget package, which is hosted here, https://github.com/spritewidget/spritewidget. Sprite Widget is an excellent package and gave me access to lower level GPU drawing. With spriteWidget I was able to achieve the performance level I desired. 

So in conclusion, Flutter is capable for most animation needs; however, for very demanding situations, your mileage may vary.

t

Laurent Forêt

unread,
Apr 13, 2018, 9:52:10 AM4/13/18
to Ted Liao, Flutter Dev
It was not a good idea, I had to install and test it, So now I have to spend some time to finish it ;). It works fine.

Thx


--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mike Roosa

unread,
Apr 13, 2018, 9:39:11 PM4/13/18
to Flutter Dev

Looks good Ted. I did notice if the score goes over 4 digits, the display of the score wraps and you can't really see it all. As far as the game goes, though, it all works fine and is smooth. Nice job.

Vijender P

unread,
Apr 13, 2018, 11:15:20 PM4/13/18
to Ted Liao, Flutter Dev
Nice work. The animations are smooth and the game is fun to play.

--

Rene Floor

unread,
Apr 15, 2018, 6:07:50 AM4/15/18
to Flutter Dev
Nice work! Would be nice if you save the state when you switch to another app.

Ted Liao

unread,
Apr 15, 2018, 8:21:04 AM4/15/18
to Flutter Dev
I don't believe Flutter has state restoration yet - https://github.com/flutter/flutter/issues/6827.  However, i think it would be easy enough to persist the game state to disk under a key, and check for this key when the app starts in the main.dart entry method.  It would be nice to be able to catch the O.S's kill event so we can save the state before the app exits, otherwise, we'd have to persist the state to disk after each move. I have the game state organized as an array of items, so it would be easy to serialize and save.

t

Michael Thomsen

unread,
Apr 18, 2018, 8:13:50 AM4/18/18
to Ted Liao, Flutter Dev
It is correct that Flutter does not have any automated state restoration. But we do expose some lifecycle events in SystemsChannels.lifecycle. For the particular case here with saving game state, I suspect you should be able to do that by listening to that channel for 'paused' events.

If you do decide to give this a go, would be great to hear some feedback on that.

On Sun, Apr 15, 2018 at 2:21 PM, Ted Liao <ekb...@gmail.com> wrote:
I don't believe Flutter has state restoration yet - https://github.com/flutter/flutter/issues/6827.  However, i think it would be easy enough to persist the game state to disk under a key, and check for this key when the app starts in the main.dart entry method.  It would be nice to be able to catch the O.S's kill event so we can save the state before the app exits, otherwise, we'd have to persist the state to disk after each move. I have the game state organized as an array of items, so it would be easy to serialize and save.

t

--
You received this message because you are subscribed to the Google Groups "Flutter Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages