","generatedCode":"
===================================================================\n--- original.js\n+++ change.js\n@@ -261,12 +261,12 @@\n \tself.isFlying = false;\n \tself.isImmune = false;\n \tself.isBoss = false;\n \t// Animation properties\n+\tself.animationFrame = 0;\n+\tself.animationTimer = 0;\n+\tself.animationInterval = 6; // Change frame every 6 ticks (100ms at 60fps)\n \tself.animationFrames = ['enemy', 'enemy1', 'enemy2', 'enemy3'];\n-\tself.currentFrame = 0;\n-\tself.frameTimer = 0;\n-\tself.frameDelay = 6; // 100ms at 60 FPS (6 frames = 100ms)\n \t// Check if this is a boss wave\n \t// Check if this is a boss wave\n \t// Apply different stats based on enemy type\n \tswitch (self.type) {\n@@ -302,21 +302,20 @@\n \tvar assetId = 'enemy';\n \tif (self.type !== 'normal') {\n \t\tassetId = 'enemy_' + self.type;\n \t}\n-\t// For normal enemies, use the animated frames\n+\t// For normal enemies, start with the first animation frame\n \tif (self.type === 'normal') {\n \t\tassetId = self.animationFrames[0];\n \t}\n-\tvar enemyGraphics = self.attachAsset(assetId, {\n+\tself.enemyGraphics = self.attachAsset(assetId, {\n \t\tanchorX: 0.5,\n \t\tanchorY: 0.5\n \t});\n-\tself.enemyGraphics = enemyGraphics; // Store reference for animation\n \t// Scale up boss enemies\n \tif (self.isBoss) {\n-\t\tenemyGraphics.scaleX = 1.8;\n-\t\tenemyGraphics.scaleY = 1.8;\n+\t\tself.enemyGraphics.scaleX = 1.8;\n+\t\tself.enemyGraphics.scaleY = 1.8;\n \t}\n \t// Fall back to regular enemy asset if specific type asset not found\n \t// Apply tint to differentiate enemy types\n \t/*switch (self.type) {\n@@ -374,42 +373,42 @@\n \thealthBar.tint = 0x00ff00;\n \thealthBarBG.tint = 0xff0000;\n \tself.healthBar = healthBar;\n \tself.update = function () {\n-\t\t// Handle animation for normal enemies only\n+\t\tif (self.health <= 0) {\n+\t\t\tself.health = 0;\n+\t\t\tself.healthBar.width = 0;\n+\t\t}\n+\t\t// Handle animation for normal enemies\n \t\tif (self.type === 'normal') {\n-\t\t\tself.frameTimer++;\n-\t\t\tif (self.frameTimer >= self.frameDelay) {\n-\t\t\t\tself.frameTimer = 0;\n-\t\t\t\tself.currentFrame = (self.currentFrame + 1) % self.animationFrames.length;\n-\t\t\t\t// Remove current graphics\n-\t\t\t\tif (self.enemyGraphics) {\n-\t\t\t\t\tself.removeChild(self.enemyGraphics);\n-\t\t\t\t}\n-\t\t\t\t// Attach new frame\n-\t\t\t\tself.enemyGraphics = self.attachAsset(self.animationFrames[self.currentFrame], {\n+\t\t\tself.animationTimer++;\n+\t\t\tif (self.animationTimer >= self.animationInterval) {\n+\t\t\t\tself.animationTimer = 0;\n+\t\t\t\tself.animationFrame = (self.animationFrame + 1) % self.animationFrames.length;\n+\t\t\t\t// Update the graphic to the new frame\n+\t\t\t\tvar newAssetId = self.animationFrames[self.animationFrame];\n+\t\t\t\t// Remove old graphic\n+\t\t\t\tself.removeChild(self.enemyGraphics);\n+\t\t\t\t// Add new graphic with current frame\n+\t\t\t\tself.enemyGraphics = self.attachAsset(newAssetId, {\n \t\t\t\t\tanchorX: 0.5,\n \t\t\t\t\tanchorY: 0.5\n \t\t\t\t});\n-\t\t\t\t// Reapply boss scaling if needed\n+\t\t\t\t// Apply boss scaling if needed\n \t\t\t\tif (self.isBoss) {\n \t\t\t\t\tself.enemyGraphics.scaleX = 1.8;\n \t\t\t\t\tself.enemyGraphics.scaleY = 1.8;\n \t\t\t\t}\n-\t\t\t\t// Apply current rotation if exists\n-\t\t\t\tif (self.enemyGraphics.targetRotation !== undefined) {\n-\t\t\t\t\tself.enemyGraphics.rotation = self.enemyGraphics.targetRotation;\n+\t\t\t\t// Reorder children to keep health bars on top\n+\t\t\t\tvar healthBars = [];\n+\t\t\t\twhile (self.children.length > 1) {\n+\t\t\t\t\thealthBars.push(self.removeChildAt(self.children.length - 1));\n \t\t\t\t}\n-\t\t\t\t// Apply current tint if any\n-\t\t\t\tif (self.currentTint !== undefined) {\n-\t\t\t\t\tself.enemyGraphics.tint = self.currentTint;\n+\t\t\t\tfor (var i = healthBars.length - 1; i >= 0; i--) {\n+\t\t\t\t\tself.addChild(healthBars[i]);\n \t\t\t\t}\n \t\t\t}\n \t\t}\n-\t\tif (self.health <= 0) {\n-\t\t\tself.health = 0;\n-\t\t\tself.healthBar.width = 0;\n-\t\t}\n \t\t// Handle slow effect\n \t\tif (self.isImmune) {\n \t\t\t// Immune enemies cannot be slowed or poisoned, clear any such effects\n \t\t\tself.slowed = false;\n@@ -465,23 +464,18 @@\n \t\t}\n \t\t// Set tint based on effect status\n \t\tif (self.isImmune) {\n \t\t\tself.enemyGraphics.tint = 0xFFFFFF;\n-\t\t\tself.currentTint = 0xFFFFFF;\n \t\t} else if (self.poisoned && self.slowed) {\n \t\t\t// Combine poison (0x00FFAA) and slow (0x9900FF) colors\n \t\t\t// Simple average: R: (0+153)/2=76, G: (255+0)/2=127, B: (170+255)/2=212\n \t\t\tself.enemyGraphics.tint = 0x4C7FD4;\n-\t\t\tself.currentTint = 0x4C7FD4;\n \t\t} else if (self.poisoned) {\n \t\t\tself.enemyGraphics.tint = 0x00FFAA;\n-\t\t\tself.currentTint = 0x00FFAA;\n \t\t} else if (self.slowed) {\n \t\t\tself.enemyGraphics.tint = 0x9900FF;\n-\t\t\tself.currentTint = 0x9900FF;\n \t\t} else {\n \t\t\tself.enemyGraphics.tint = 0xFFFFFF;\n-\t\t\tself.currentTint = 0xFFFFFF;\n \t\t}\n \t\tif (self.currentTarget) {\n \t\t\tvar ox = self.currentTarget.x - self.currentCellX;\n \t\t\tvar oy = self.currentTarget.y - self.currentCellY;\n@@ -515,9 +509,9 @@\n \t\t\t\t\t}\n \t\t\t\t}\n \t\t\t}\n \t\t}\n-\t\thealthBarOutline.y = healthBarBG.y = healthBar.y = -enemyGraphics.height / 2 - 10;\n+\t\thealthBarOutline.y = healthBarBG.y = healthBar.y = -self.enemyGraphics.height / 2 - 10;\n \t};\n \treturn self;\n });\n var GoldIndicator = Container.expand(function (value, x, y) {\n
"} Upit | Learn about creating the game THE LAST LINE with gen AI