dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Level Restart On A Flash Game

  1. #1
    Member
    Join Date
    Apr 2007
    Posts
    55

    Level Restart On A Flash Game

    Hello Everyone,
    i have a question..

    my game using many runtime objects , variables , etc..

    in the timeLine 2nd Frame the script will be executed and the main game Loop also in 2nd frame.. also many include files are imported for each actions. (*.AS) files.

    how can i do a restart level on my game ? maybe any ideas ?
    i just tried few codes.. but i am not sure.. about unloading all objects , variables to Clear The Memory

    so..it won't loss the FPS anymore.

    Any Example Code / Idea ....

    Thanks..
    Last edited by tharshan; 05-26-2007 at 02:44 PM.

  2. #2
    Banned
    Join Date
    Mar 2007
    Location
    Albania , prishtina
    Posts
    274
    Can u post your file(s) , plz ...

    .PumI.

  3. #3
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    What you want is a robust init() function. Don't let any of your code fire automatically. Put all the start up variables and initial commands inside a big function. When your movie is loaded, the init function should set the starting values of your variables, create empty arrays, set timers to zero etc. Essentially you should be able to just be able to run init() at anytime.

  4. #4
    Member
    Join Date
    Apr 2007
    Posts
    55
    Quote Originally Posted by jAQUAN
    What you want is a robust init() function. Don't let any of your code fire automatically. Put all the start up variables and initial commands inside a big function. When your movie is loaded, the init function should set the starting values of your variables, create empty arrays, set timers to zero etc. Essentially you should be able to just be able to run init() at anytime.
    Thanks For Your Reply.

    i have a question..
    in the games.. player will press "retry" many times..
    Calling init() multiple time will decrease the FPS .. OR will the variables automaticly cleared from memory ?

  5. #5
    Member
    Join Date
    Apr 2007
    Posts
    55

    thanks.

    my game method is :


    -- VARIABLE DECLARATION & INCLUDE THE .AS FILES.

    -- FUNCTIONS () - to call them later.

    -- LEVEL ,OBJECT CREATION FUNCTION () - it will create the level , object from code..

    -- Main Game Loop ()


    any ideas / common method will be welcome.

  6. #6
    Senior Member
    Join Date
    Apr 2001
    Posts
    175
    Flash is garbage collected, so it will automatically reclaim objects if there is no longer any reference to them. However, you have to make sure to explicitly remove any movie clips you created once you're not using them any more, because otherwise Flash will retain them. Just keep track of all the movie clips you create, and make sure to call removeMovieClip() on them once they are no longer needed (for example, if an enemy dies and then fades away, you should remove it).

  7. #7
    Member
    Join Date
    Apr 2007
    Posts
    55

    thanks

    thanks for your Tips..

    yes i am removing the MovieClips like that.

    but for most of movieClips i am using : unloadMovie(); command.
    is there any different between unLoadMovie(); AND removeMovieClip(); ?


    Quote Originally Posted by Flecko
    Flash is garbage collected, so it will automatically reclaim objects if there is no longer any reference to them. However, you have to make sure to explicitly remove any movie clips you created once you're not using them any more, because otherwise Flash will retain them. Just keep track of all the movie clips you create, and make sure to call removeMovieClip() on them once they are no longer needed (for example, if an enemy dies and then fades away, you should remove it).

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