Code edit (1 edits merged)
Please save this source code
User prompt
Migrate to the latest version of LK
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading '0')' in this line: 'levelText.setText('Level ' + (currentLevel + 1) + ' - Get ' + levels[currentLevel][0] + ' out of ' + levels[currentLevel][1] + ' shapes');' Line Number: 232
Code edit (19 edits merged)
Please save this source code
User prompt
in on tick if (currentLevel == levels.length) call game over
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -188,8 +188,9 @@
};
game.expandedCount = 1;
game.setBackgroundColor('0xCCCCFF');
var currentLevel = 0;
+var playerScore = 0;
var levels = [[1, 5], [3, 7], [6, 9], [8, 12], [10, 15], [15, 20], [18, 25], [25, 32], [30, 40], [35, 50], [50, 65], [75, 75]];
var shapes = [];
var levelText = new Text2('Level 1 - Get 1 out of 5 shapes', {
size: 80,
@@ -231,8 +232,9 @@
LK.on('tick', function () {
if (game.expandedCount == 0) {
if (collisionsCount >= levels[currentLevel][0]) {
collisionText.setText('Level Completed - now try this');
+ playerScore += collisionsCount;
currentLevel++;
} else {
collisionText.setText('Try again');
}
@@ -241,8 +243,9 @@
});
shapes = [];
if (currentLevel == levels.length) {
collisionText.setText('Good Job!\nAll levels completed!\nYou win :)');
+ LK.setScore(playerScore);
LK.showGameOver();
return;
}
for (var i = 0; i < (levels[currentLevel] ? levels[currentLevel][1] : 0); i++) {
a white geometric square shape Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a white dot Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
flat white round disk Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
gif circle spinning animation Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.