Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'monkeyAsset = self.attachAsset(newAssetId, {' Line Number: 95
Code edit (5 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'monkeyAsset = self.attachAsset(newAssetId, {' Line Number: 95
Code edit (6 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: ticksBeforeNextPosition is not defined' in or related to this line: 'scoreTest = "actualPIx: " + self.actualPositionIndex + " goalPIx: " + self.goalPositionIndex + " assetsToUse: " + self.assetsToUse + " seqIxToUse: " + self.sequenceIndexToUse + "\nticksBeforeNextPosition: " + ticksBeforeNextPosition;' Line Number: 114
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'monkeyAsset = self.attachAsset(newAssetId, {' Line Number: 96
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'monkeyAsset = self.attachAsset(newAssetId, {' Line Number: 96
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'monkeyAsset = self.attachAsset(newAssetId, {' Line Number: 96
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'monkeyAsset = self.attachAsset(newAssetId, {' Line Number: 96
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'length')' in or related to this line: 'monkeyAsset = self.attachAsset(newAssetId, {' Line Number: 94
Code edit (13 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of null (reading 'trajectory')' in or related to this line: 'coconutChoosen.trajectory.isStarted = true;' Line Number: 138
Code edit (1 edits merged)
Please save this source code
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot read properties of undefined (reading 'anchorX')' in or related to this line: 'monkeyAsset = self.attachAsset(newAssetId, {' Line Number: 69
Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Cannot set properties of undefined (setting 'anchorX')' in or related to this line: 'monkey.monkeyAsset.anchorX = 0.91;' Line Number: 421
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: initialAsset is not defined' in or related to this line: 'self.removeChild(initialAsset);' Line Number: 66
Code edit (1 edits merged)
Please save this source code
Code edit (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'x')' in or related to this line: 'monkey.sprite.x = 2048 / 2;' Line Number: 246
===================================================================
--- original.js
+++ change.js
@@ -42,9 +42,9 @@
self.assetsToRight = ['monkeyToRight', 'monkeyInterRight'];
self.assetsToLeft = ['monkeyToLeft', 'monkeyInterLeft'];
self.sequenceIndexToCenter = [0, 1, 0];
self.sequenceIndexToExtreme = [0, 1, 0, 1, 0];
- self.assetsToUse = [];
+ self.assetsToUse = self.assetsToUse || [];
self.sequenceIndexToUse = []; //Séquence des index des assets du monkey a utiliser
self.sequenceIndex = 0; //Index de la séquence des assets du monkey
self.actualPositionIndex = 0; //Positions de depart : 0 (XL), 1 (XC), 2 (XR) index du tableau startPoints
self.goalPositionIndex = 0; //Positions d'arrivée : 0 (XL), 1 (XC), 2 (XR) index du tableau startPoints
@@ -66,11 +66,13 @@
//scoreTest = "actualPositionIndex: " + self.actualPositionIndex + " goalPositionIndex: " + self.goalPositionIndex;
}; //fin setMoveToGoalPosition
// Function to change the asset
self.changeAsset = function (newAssetId, options) {
- // Remove the existing asset
- self.removeChild(monkeyAsset);
- monkeyAsset.destroy();
+ // Remove the existing asset if it exists
+ if (monkeyAsset) {
+ self.removeChild(monkeyAsset);
+ monkeyAsset.destroy();
+ }
// Attach the new asset
monkeyAsset = self.attachAsset(newAssetId, {
anchorX: options && options.anchorX !== undefined ? options.anchorX : 0.5,
anchorY: options && options.anchorY !== undefined ? options.anchorY : 0.5
@@ -89,9 +91,9 @@
self.assetsToUse = self.assetsToLeft;
}
self.sequenceIndexToUse = Math.abs(self.actualPositionIndex - self.goalPositionIndex) == 1 ? self.sequenceIndexToCenter : self.sequenceIndexToExtreme;
self.ticksBeforeNextPosition = self.ticksToGoToGoalPosition / self.sequenceIndexToUse.length;
- //self.isMoving = true;
+ self.isMoving = true;
self.ticksBeforeNextPosition = self.ticksToGoToGoalPosition / self.sequenceIndexToUse.length;
scoreTest = "actualPIx: " + self.actualPositionIndex + " goalPIx: " + self.goalPositionIndex + " assetsToUse: " + self.assetsToUse + " seqIxToUse: " + self.sequenceIndexToUse + "\nticksBeforeNextPosition: " + self.ticksBeforeNextPosition;
} else if (self.isMoving) {
if (self.isGoingToRight) {
@@ -117,9 +119,9 @@
self.isGoingToRight = false;
self.isGoingToLeft = false;
self.sequenceIndex = 0;
self.assetsToUse = [];
- self.sequenceIndexToUse = [];
+ self.sequenceIndexToUse = self.sequenceIndexToUse || [];
if (self.coconutChoosen) {
self.coconutChoosen.trajectory.isStarted = true; //On lache la coconut
self.coconutChoosen = null;
}
@@ -313,9 +315,9 @@
var sommetParaboleBasse = ScoreZone.height + 400;
var nbTicksToBounceHight = 230; //Nombre de ticks pour effectuer une parabole haute
var nbTicksTobounceLow = 220; //Nombre de ticks pour effectuer une parabole basse
var nbTicksToFall = 200; //Nombre de ticks pour tomber
-var nbTicksBeforeThrow = 2000;
+var nbTicksBeforeThrow = 200;
var nbTicksLeftBeforeNextThrow = 0;
var score = 0;
var scoreTest = 0;
var startPoints = [XL = game.width / 4, XC = game.width / 2, XR = 3 * game.width / 4]; // Define the startPoints array
@@ -673,9 +675,9 @@
if (coconutChoosen == null) {
coconutChoosen = chooseNextCoconut();
//coconutChoosen.trajectory.isStarted = true;
//game.addChild(coconutChoosen);
- monkey.setMoveToGoalPosition(coconutChoosen, nbTicksLeftBeforeNextThrow);
+ monkey.setMoveToGoalPosition(coconutChoosen, nbTicksBeforeThrow);
} else {
nbTicksLeftBeforeNextThrow = nbTicksBeforeThrow;
coconutChoosen = null;
}