Multiple Screens, or Simulated Multiple Screens in App Inventor 2? What's the Best Way?

618 views
Skip to first unread message

gregp...@gmail.com

unread,
Mar 6, 2014, 10:05:02 AM3/6/14
to mitappinv...@googlegroups.com
Windows 7 Ultimate, AI2, Chrome, Samsung S3
I've been watching Youtube vids about multiple screens in App Inventor. One guy simulates it by using verticle arrangements and switching between them. Yet another uses multiple canvases to simulate multiple screens. Also, a guy demonstrates the use of multiple screens but only uses two screens (all these vids appear to be AI Classic code). Further research leads me to: Using beyond two screens requires a tinyDB.

I'm creating a game that could have 10 - 20 levels, memory permitting. So has anyone used true multiple screens to this extent? The fact that you get a clean slate for each screen leads me to think there'd be a lot of duplicate code. So maybe either the multiple canvases or multiple verticle arrangements would be the way to go? I'm thinking a canvas is more memory than a verticle arrangement, does anybody know if this is the case?

Also, is a global variable created in Screen1 addressable in Screen2, if I go the true multiple screen approach?

I'm basing my above memory apprehension on creating the drum app I watched on Youtube, none of my sounds will play, and I did read the sound info etc. Also I can't get a vector image to work as an icon on another app.

Hal Abelson

unread,
Mar 8, 2014, 7:54:36 PM3/8/14
to mitappinv...@googlegroups.com, gregp...@gmail.com
Icons need to be JPG or PNG, 48x48

You have a great question.  That kind of efficiency issue is something that people ignore, and then get into trouble with large apps.   I'd suggest using vertical arrangements.  A second screen adds a lot of overhead: each screen is effectively a complete app.   So a multiscreen app with many screens is a big load.   A canvas is a lot less than a complete scrre.  But each canvas includes the overhead for its event handlers.   So if all you want is a set of images whose visibility you can control, use a vertical  arrangement.

== Hal

gregp...@gmail.com

unread,
Mar 12, 2014, 3:23:12 PM3/12/14
to mitappinv...@googlegroups.com, gregp...@gmail.com
Thanks for the info on icons, I'll try that. In addition, thank you for responding to my post.

By the time I read your post I had already coded this part of my game using the Screen approach. Moreover, props to http://puravidaapps.com/manager.php for their info on this topic. As I had read on http://ai2.appinventor.mit.edu/, puravidaapps stressed the importance of closing a screen before opening a new screen. Regardless, I started out NOT doing that just to see if I could break my app, and therefore prove the necessity to close each screen, etcetera. It took about 15 - 20 screen changes but I did break my app. 

So far my app is doing well with the close a screen, open a new screen approach. Although, I'm running a 16 GB Samsung S3, so I better test on some lower memory phones to see what'll happen. 

But when I think about it, I didn't see much of a size increase from one screen to 10 screens: 2 Screens   1687 KB, 10 screens   1698KB
Reply all
Reply to author
Forward
0 new messages