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
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (12 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: oconutsInTree is not defined' in or related to this line: 'oconutsInTree.push(newCoconut);' Line Number: 338
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (19 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: coconut is not defined' in or related to this line: 'scoreTest = "Zone contact = " + zoneIntersectParasol(coconut[i]);' Line Number: 434
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
Code edit (16 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: livesLeftGraphics[i] is undefined' in or related to this line: 'livesLeftGraphics[i].destroy();' Line Number: 264
Code edit (1 edits merged)
Please save this source code
Code edit (7 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: Sprite is not a constructor' in or related to this line: 'var newLife = new Sprite('life');' Line Number: 267
Code edit (12 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: scor is not defined' in or related to this line: 'scor += 1;' Line Number: 120
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: OptionsZone is undefined' in or related to this line: 'parasol.y = OptionsZone.y - 400;' Line Number: 189
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);