Copy link to clipboard
Copied
I have a movie clip (enemy) inside the enemy i have 3 frames for iddle, attack and run.The enemies are inside Array.What is the better way to cache as bitmap the enemy and movie clips inside the enemy?
var greengoblinVelocity: int = 0;
var e: int;
for (e = numChildren - 1; e >= 0; e--)
{
var childdE: DisplayObject = getChildAt(e);
if (childdE.name.indexOf("enemy") > -1)
{
GreenGoblinArray.push(MovieClip(childdE));
MovieClip(childdE).hitPoints = 2;
MovieClip(childdE).currentX = 0;
MovieClip(childdE).startAttack = 0;
}
}
stage.addEventListener(Event.ENTER_FRAME, gameloop);
function gameloop(event: Event😞 void
{
for (var enl = 0; enl < GreenGoblinArray.length; enl++)
{
var enemy: Enemy = GreenGoblinArray[enl] as Enemy;
}
}
Copy link to clipboard
Copied
it doesn't make any sense to cacheAsBitmap a movieclip that will be changing frames more than rarely.
create 3 movieclips of the 3 frames and cache each of them if there's enough memory and a significant performance benefit.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now