A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Game: runs slower and slower

  1. #1
    Junior Member
    Join Date
    Oct 2003
    Posts
    7

    Game: runs slower and slower

    I have made a game in which you must run through a maze.
    The x and y positions of the walls are set by random.
    You must destroy all the enemies with your bombs to get to the next level. (exit -> is behind the bushes - bomb them)
    (in reality -> when you get to the next level - the game simply restarts)

    Problem: the game runs slower and slower each time you get to the next level

    Please, HELP !!!!!!
    Attached Files Attached Files

  2. #2
    Belgian member znoskieman's Avatar
    Join Date
    Jul 2003
    Location
    Belgium
    Posts
    280
    Unexpected file format. What version of flash do you use?
    http://www.leukestart.be

  3. #3
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    I converted fla to PC format

    I dont see the code to check for the dead enemies? Where do you actually change the level?

  4. #4
    DOT-INVADER marmotte's Avatar
    Join Date
    May 2002
    Location
    Dot-Switzerland
    Posts
    2,601
    there's something you forgot to reset...
    maybe the variable you are using to count the enemies, combined with a hitTest?

    I converted fla to PC format
    what does that mean? it's a mac fla file? if so, there's absolutely no compatibility issue...

  5. #5
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Originally posted by marmotte
    what does that mean? it's a mac fla file? if so, there's absolutely no compatibility issue... [/B]
    yea there is. Some Mac files dont open in PC (I really dont know why), so I have to delete part from it in the beginning for Flash to open it.

  6. #6
    DOT-INVADER marmotte's Avatar
    Join Date
    May 2002
    Location
    Dot-Switzerland
    Posts
    2,601
    ha, i think i had that problem once with one of my files... strange thing, i just compressed it (.zip) and it opened correctly...
    so it's maybe a header problem...

  7. #7
    Senior Member
    Join Date
    Jun 2000
    Posts
    896
    Hi a_christian,

    I did not look at your source file. But I can tell you what usually causes something like this (other than the obvious case where too much is going on).

    Typically, if your game just gets slower and slower for no apparent reason, then you have a memory leak.

    A memory leak occurs when stored data is not getting cleaned up. In the case of Flash 4 there really was no easy way around this since you couldn't use local vars and there was no 'delete' keyword. In Flash 5, MX, and MX 2004 you have options for better memory management.

    The answer is to go through your code and clean it up a bit. Lets say you have this function

    Code:
    function moveCharacter() {
    	temp_x = current_x+30;
    	temp_y = current_y+20;
    	char._x = temp_x;
    	char._y = temp_y;
    }
    Well, temp_x and temp_y are just used as auxilary variables. They are just used temporarily to arrive at a new result. When the function is done you dont need them any longer. So they should be local variables, declared with 'var' syntax, such as:

    Code:
    function moveCharacter() {
    	var temp_x = current_x+30;
    	var temp_y = current_y+20;
    	char._x = temp_x;
    	char._y = temp_y;
    }
    That way they are removed from memory when the function is finished.

    It is a very common problem for a person to code a game (say 600+ lines of code) where no local variables are used. In that case, the Flash player will have to keep track of a buttload of data that it shouldn't be.

    Hope this helps.

  8. #8
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,223
    Hey, Jobe, grats on new book

  9. #9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center