MIT App Inventor emulator freezes every 4 seconds (plants vs zombies game)

I am trying to make a plants vs zombies game in mit app inventor for a computer project, and so far I have the map, peashooter, and sunflower done. I am not changing images of sprites rapidly, and my only clock runs every 200 ms. I think the problem might have something to do with changing the visibility of sprites rapidly though, because every time a peashooter fires it has to make a peashooter bullet sprite visible and enabled, and set its location. When it reaches the end of the canvas it has to make it invisible and unenable it. The sunflower basically does the same thing. Does anyone know a solution?

How are you moving your sprites?

  • By speed and direction, or
  • by Clock driven X and Y displacements?

Do you have Edge Reached events?

speed and direction, and yes i habe edge reached events

How about built, on a real device?

Built, on an emulator?

Alternative emulators:

App Inventor is not a lighting fast game engine.

Things you can do

  • start programing in Android Studio or an Android compiler for games. AI's graphics is among the slowest of any Android compiler
  • your clock fires every 200 ms. A human eyeblink is about 400 ms. Try a slower Clock and see if it improves speed without seriously affecting game play. It may even prevent freezing which is garbage collection while the system memory is overtaxed.
  • emulator!!!!!!! :cry: a real Android cpu is faster; your app might run faster if you tried a real device; not an emulator.
  • your images; are they the same size as used in the app. Don't use images that are large; avoid depending on the app to resize them to fit your sprite size. Auto resizing takes time and cpu.

Try some stuff. Others will have suggestions. Remember you are coding with a Ladda, not a race car. Good luck. The best action games I ever programed were in machine language but App Inventor can still build some fun games.

1 Like