Code edit (4 edits merged)
Please save this source code
Code edit (17 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: path.setupPlayer is not a function' in or related to this line: 'path.setupPlayer(player);' Line Number: 393
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: LK.playSound is not a function' in or related to this line: 'LK.playSound('step_disappear');' Line Number: 232
User prompt
when a path step disapear, a sound fx should be played.
===================================================================
--- original.js
+++ change.js
@@ -9,9 +9,9 @@
anchorX: 0.5,
anchorY: 0.5
});
self.rotateAround = function (otherBall) {
- self.angle += 0.025 * (path.level + 1);
+ self.angle += 0.025 * (path.level * 0.5 + 1);
self.rotation = self.angle + 1.57;
otherBall.rotation = self.rotation + 3.14;
self.x = otherBall.x + otherBall.width * 2 * Math.cos(self.angle);
self.y = otherBall.y + otherBall.width * 2 * Math.sin(self.angle);
@@ -42,8 +42,19 @@
});
});
var Path = Container.expand(function (level) {
var self = Container.call(this);
+ self.setupPlayer = function (player) {
+ self.curStep = 0;
+ for (var i = 0; i < 3; i++) {
+ self.nextStep();
+ }
+ if (self.pathPositions && self.pathPositions[0]) {
+ player.init(self.pathPositions[0].x, self.pathPositions[0].y);
+ } else {
+ console.error('Path positions not defined');
+ }
+ };
LK.setScore(level);
self.level = level;
self.levels = [
// level 0
@@ -59,8 +70,55 @@
}, {
x: 1024,
y: 1800
}],
+ // level 2
+ [{
+ x: 1024,
+ y: 2400
+ }, {
+ x: 883,
+ y: 2259
+ }, {
+ x: 742,
+ y: 2118
+ }, {
+ x: 601,
+ y: 1977
+ }, {
+ x: 601,
+ y: 1777
+ }, {
+ x: 742,
+ y: 1636
+ }, {
+ x: 942,
+ y: 1636
+ }, {
+ x: 1024,
+ y: 1818
+ }, {
+ x: 1106,
+ y: 1636
+ }, {
+ x: 1306,
+ y: 1636
+ }, {
+ x: 1447,
+ y: 1777
+ }, {
+ x: 1447,
+ y: 1977
+ }, {
+ x: 1306,
+ y: 2118
+ }, {
+ x: 1165,
+ y: 2259
+ }, {
+ x: 1024,
+ y: 2400
+ }],
// level 1
[{
x: 1024,
y: 2400
@@ -159,8 +217,9 @@
y: 200
}]];
if (self.level >= self.levels.length) {
LK.showGameOver();
+ return;
}
self.pathSteps = [];
self.pathPositions = self.levels[self.level];
self.addPathStep = function (position) {
@@ -184,9 +243,9 @@
}
};
self.setupPlayer = function (player) {
self.curStep = 0;
- for (var i = 0; i < 10; i++) {
+ for (var i = 0; i < 3; i++) {
self.nextStep();
}
if (self.pathPositions && self.pathPositions[0]) {
player.init(self.pathPositions[0].x, self.pathPositions[0].y);
@@ -229,8 +288,13 @@
ball1.y = y;
ball1.rotating = false;
ball2.rotating = true;
};
+ self.IsMatching = function IsMatching(obj1, obj2) {
+ var diffX = obj1.x - obj2.x;
+ var diffY = obj1.y - obj2.y;
+ return diffX * diffX + diffY * diffY <= 2000;
+ };
self.click = function () {
var tempRotating = ball1.rotating;
ball1.rotating = ball2.rotating;
ball2.rotating = tempRotating;
@@ -243,13 +307,13 @@
var onStep2 = false;
var smallPathStep = 9999;
for (var i = 0; i < path.pathSteps.length; i++) {
if (path.pathSteps[i]) {
- if (IsMatching(path.pathSteps[i], ball1)) {
+ if (self.IsMatching(path.pathSteps[i], ball1)) {
onStep1 = true;
smallPathStep = Math.min(smallPathStep, i);
}
- if (IsMatching(path.pathSteps[i], ball2)) {
+ if (self.IsMatching(path.pathSteps[i], ball2)) {
onStep2 = true;
smallPathStep = Math.min(smallPathStep, i);
}
}
@@ -264,8 +328,15 @@
starFX.direction = i;
game.addChild(starFX);
starFX.playFX();
}
+ if (ball1.rotating) {
+ ball2.x = path.pathSteps[smallPathStep + 1].x;
+ ball2.y = path.pathSteps[smallPathStep + 1].y;
+ } else {
+ ball1.x = path.pathSteps[smallPathStep + 1].x;
+ ball1.y = path.pathSteps[smallPathStep + 1].y;
+ }
path.pathSteps[smallPathStep].disapear();
path.pathSteps.splice(smallPathStep, 1);
path.nextStep();
if (path.pathSteps.length == 1) {
@@ -311,16 +382,11 @@
/****
* Game Code
****/
-// Initialize player ship asset
-// Initialize obstacle asset
// Initialize background stars
-var IsMatching = function IsMatching(obj1, obj2) {
- var diffX = obj1.x - obj2.x;
- var diffY = obj1.y - obj2.y;
- return diffX * diffX + diffY * diffY <= 1000;
-};
+// Initialize obstacle asset
+// Initialize player ship asset
function showCongratsPopup() {
game.removeChild(path);
game.removeChild(player);
path = new Path(path.level + 1);
tête de mort rouge. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
tête de mort coter droit en bleu coter gauche en rouge. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
tourbillon bleu et rouge. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
bone. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
tourbillon rouge et bleu. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.