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
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -13,9 +13,8 @@
self.Xintercept = 0; //Abscisse d'interception du coconut avec le parasol
self.Yintercept = 0; //Ordonnée d'interception du coconut avec le parasol
self.trajectory = new Trajectory();
self.update = function () {
- scoreTest = "trajectory.isFalling: " + self.trajectory.isFalling;
if (self.trajectory.typeTrajectory == -1) {
self.trajectory.updateStatic();
}
if (self.trajectory.typeTrajectory == 0) {
@@ -26,9 +25,8 @@
}
self.y = self.trajectory.y;
self.x = self.trajectory.x;
self.isFalling = self.trajectory.isFalling;
- scoreTest += " / self.isFalling: " + self.isFalling;
if (self.y > 2732) {
self.destroy();
}
}; //fin update
@@ -36,12 +34,16 @@
//<Assets used in the game will automatically appear here>
// Class for the Monkey
var Monkey = Container.expand(function () {
var self = Container.call(this);
- var monkeyGraphics = self.attachAsset('monkey', {
+ self.monkeySprite = LK.getAsset('monkey', {
anchorX: 0.5,
anchorY: 0.5
});
+ //var monkeyGraphics = self.attachAsset('monkey', {
+ // anchorX: 0.5,
+ // anchorY: 0.5
+ //});
self.update = function () {
// Monkey logic can be added here
};
});
@@ -216,11 +218,13 @@
/****
* Autres
****/
var monkeyLevel = 200;
-var monkey = game.addChild(new Monkey());
-monkey.x = 2048 / 2;
-monkey.y = monkeyLevel;
+//var monkey = game.addChild(new Monkey());
+var monkey = new Monkey();
+game.addChild(monkey);
+monkey.monkeySprite.x = 2048 / 2;
+monkey.monkeySprite.y = monkeyLevel;
var parasol = game.addChild(new Parasol());
parasol.x = 2048 / 2;
parasol.y = OptionsZone.y - 400;
var coconutsInTree = []; //Tableau des coconuts dans les arbres
@@ -367,8 +371,9 @@
function chooseNextCoconut() {
var randomIndex = Math.floor(Math.random() * coconutsInTree.length);
var newCoconut = coconutsInTree[randomIndex];
coconutsInTree.splice(randomIndex, 1);
+ moveMonkeyToCoconut(newCoconut);
var typeTrajectory = 0; //Trajectoire linéaire
newCoconut.isFalling = true;
var X1 = newCoconut.x;
var X2 = X1;
@@ -376,19 +381,19 @@
var Yh = newCoconut.y;
var totalTicks = 500;
newCoconut.trajectory.setParameters(typeTrajectory, X1, X2, Y0, Yh, totalTicks);
coconuts.push(newCoconut);
- moveMonkeyToStartPoint(X1, monkeyLevel);
return newCoconut;
} //fin chooseNextCoconut
-//Fonction moveMonkeyToStartPoint: déplace le monkey au point de départ du coconut
-function moveMonkeyToStartPoint(x, y) {
+//Fonction moveMoveMonkeyToCoconut: déplace le monkey au point de depart du coconut
+function moveMonkeyToCoconut(coconut) {
//Efface le monkey de l'écran
game.removeChild(monkey);
- monkey.x = x;
- monkey.y = y;
+ monkey.x = coconut.x;
+ monkey.y = coconut.y;
+ coconut.trajectory.isStarted = true;
game.addChild(monkey);
-} //fin moveMonkeyToStartPoint
+} //fin moveMonkeyToCoconut
//Fonction checkPosition : donne la position XL, XC, ou XR la plus proche de la position x du parasol
function checkPosition(parasol) {
var deltaX = Math.abs(parasol.x - XL);
var deltaY = Math.abs(parasol.x - XC);