Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am not sure if I will be able to provide enough information for someone to answer this question, but any ideas might help.

I am creating a tower defense game in Flash and I eventually want to make it run on Android. Just for testing purposes, I have been running it on Android's browser and different Android .swf player apps.

Recently, the game stopped working correctly. When it gets to the second wave of enemies, they get about four tiles in and stop moving. I can get them to start moving again by constantly clicking on parts of the screen. It's almost like the game loop has quit updating.

Trying to solve the problem, I have updated the gameloop from Flash's standard events to a NativeSignal event (didn't solve the problem but the game runs much faster overall).

The game works fine on my PC, I can't figure out the Android problem though. Any ideas or help would be appreciated. I didn't want to supply code since I wouldn't know where to start that would be helpful.

share|improve this question
add comment

5 Answers

up vote 0 down vote accepted

I've had exactly the same problem with a game of my own. In my case it seemed to happen at random moments. I think this happens when the enterFrame handler does not finish the frame before new enterFrame events happen. In that case the result is not displayed properly unless other events also happen.

I lowered the frame rate, and the problem seemed to have gone away (I didn't test it thoroughly, because I eventually ported the game to Java). I didn't test on Flash 10.3 yet, though. Maybe they fixed the problem there. I am interested to see if this works for you.

share|improve this answer
    
I was thinking that might have been the problem, but I am not sure. I have an option in my game to increase the speed. To do that, I just change the frame rate from 30 to 60 fps. I tried leaving it in 30 fps and still had the problem. Is there a better way to increase the game's speed? Should I have an function that doubles the speed of the tower firerate and enemy movement instead of changing the frame rate? –  Sean May 26 '11 at 15:49
    
@Sean OK, so it appears it was not the frame rate. I want to keep an eye out for this issue. Thanks for keeping us informed. About the game speed: in some games I use a global variable "gamespeed" that is multiplied with all timers and speeds in a game. –  Boris van Schooten May 26 '11 at 21:22
add comment

I'm not familiar with running flash content on Android, but I can think of two things that could cause your issue:

  1. Make sure your code is error free. The flash player that's usually installed in desktop browsers is quite forgiving in that regard and sometimes continues to run, even if an error was thrown. Install the debug-version of the flash player for your browser and check if you get any error messages (usually they will open in a popup-window).

  2. Mobile devices tend to have a lot less memory available for apps than the average desktop PC. Make sure your game is memory efficient and doesn't leak memory! You can leak memory with flash pretty easily, even though it's managed code.

I don't know what software you use to develop that game. If you're using FlashDevelop or FlashBuilder, you can profile/debug your game and look for memory-leaks and errors.

share|improve this answer
    
I just recently started using FlashDevelop. I have completely rewritten my game loop and most of the code that uses it. I have solved the problem, but I am not sure what I did. How do I use FlashDevelop to find memory-leaks? –  Sean May 26 '11 at 13:02
    
@Sean: I'm using FlashBuilder myself, so I don't know exactly how to use the profiler in FlashDevelop. But maybe this link can help you with the setup: flashdevelop.org/community/viewtopic.php?f=9&t=7330 –  bummzack May 26 '11 at 13:52
add comment

I've stumbled into the very same problem lately. The game advanced only when touching the screen. From what I have found in various articles, it may have something to do with the CPU throttling that the Flash Player uses on mobile devices. Going into fullscreen removed the problem for me.

share|improve this answer
add comment

maybe it just stuck in some function in the main loop so that any other event(like touch event) make them step one point but the main loop event doesn't happen any more.

share|improve this answer
    
I have been going through the loop looking for something that would cause it. So far, I can't find anything. The problem happens in the exact same spot every time, but only on the Android. –  Sean May 25 '11 at 23:29
    
maybe it's caused by some other event stucking in an infinite while so default flash loop hangs in there (not the main update event some other event that is called on every loop), and check if it maybe caused by case sensitivity. for example you are trying to draw some object which name is not the same case as the asset. –  Ali.S May 26 '11 at 0:05
add comment

I am not sure what was happening. I am sure one of the answers was probably the problem, but I couldn't find it specifically. I rewrote my game loop and a lot of the other code that worked with it and the problem is gone.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.