I started working on a very simple game with a friend a week ago, but now I can't seem to solve one problem:
Every level I 'attachMovie' and 'duplicateMovie开发者_高级运维' the 'hero', blocks, ground and pigs. But when you either lose or win a level, those mc's keep existing in all the other frames...
just to show you how I instantiate those movieclips:
_root.attachMovie("ground", "ground", _root.getNextHighestDepth());
and for example going to the main menu when lost is like:
gotoAndStop("main");
I've got four frames in my timeline: main menu -> choosing level -> level 1 -> level 2
can anybody help me setup my game?
thanks in advance, Dalionzo
First of all, I am not a big fan of AS2. I should have used AS3 and a Array/Vector to manage the disposal of the movieclips.
But, here is two alternate solutions.
When you add a new Movieclip to root it will not be deleted when changing frame because root is global. This means it spans over the whole timeline no matter what frame is active. An easy fix is to add holder movieclips at each frame and then add your movieclips to the holders. That will make flash remove the contents of the holder when you change frame. Another solution is to add all created mcs to an array and then loop through it to remove them when you change frame.
精彩评论