Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'getLocalPosition')' in this line: 'var pos = event.getLocalPosition(self.parent);' Line Number: 229
User prompt
Fix Bug: 'ReferenceError: obj is not defined' in this line: 'var pos = obj.event.getLocalPosition(self.parent);' Line Number: 229
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'getLocalPosition')' in this line: 'var pos = event.getLocalPosition(self.parent);' Line Number: 229
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'getLocalPosition')' in this line: 'var pos = event.getLocalPosition(self.parent);' Line Number: 229
User prompt
Fix Bug: 'TypeError: child.move is not a function' in this line: 'child.move();' Line Number: 526
User prompt
Fix Bug: 'TypeError: child.move is not a function' in this line: 'child.move();' Line Number: 530
User prompt
Fix Bug: 'TypeError: child.move is not a function' in this line: 'child.move();' Line Number: 530
Code edit (1 edits merged)
Please save this source code
User prompt
when left click is pressed, move the crosshair to that location
User prompt
Fix Bug: 'Timeout.tick error: Cannot read properties of undefined (reading 'activeMagicCount')' in this line: 'self.gameInstance.activeMagicCount++;' Line Number: 528
User prompt
Fix Bug: 'Cannot read properties of undefined (reading 'activeMagicCount')' in this line: 'self.gameInstance.activeMagicCount++;' Line Number: 528
User prompt
Make sure that instances of Magic are being correctly created and added to the game. For instance, when a BadElf shoots magic, it should instantiate a Magic object and add it to the game.
User prompt
Ensure that (LK.on('tick', function() {...})) is actively running and calling the move function for each Magic instance.
User prompt
// Inside the Magic move function console.log("Distance: " + distance + ", Threshold: " + hitThreshold);
User prompt
// Inside the Magic move function console.log("Santa X: " + santa.x + ", Y: " + santa.y); console.log("Distance: " + distance + ", Threshold: " + hitThreshold);
User prompt
Inside the Magic move function console.log("Magic X: " + self.x + ", Y: " + self.y); console.log("Santa X: " + santa.x + ", Y: " + santa.y); console.log("Distance: " + distance + ", Threshold: " + hitThreshold);
User prompt
// Inside the Magic move function console.log("Magic X: " + self.x + ", Y: " + self.y); console.log("Santa X: " + santa.x + ", Y: " + santa.y); console.log("Distance: " + distance + ", Threshold: " + hitThreshold);
User prompt
Confirm that the coordinate systems of Magic and Santa are aligned. For example, if one set of coordinates is relative to a parent container and the other is global, the distance calculation would be incorrect.
User prompt
modify the hitThreshold to a very large number to see if the collision detection is triggered
User prompt
do not apply a scaling factor to the width of magicGraphics and santaGraphics.
User prompt
(santaWidth + magicWidth) / 4 try (santaWidth + magicWidth) / 2
User prompt
delete: self.santaGraphics.scale.x = 800;
User prompt
delete: self.santaGraphics.scale.x = 800 / self.santaGraphics.width;
User prompt
santaGraphics` = 800x, 800y , and `magicGraphics = 125x, 125y
===================================================================
--- original.js
+++ change.js
@@ -23,8 +23,25 @@
magicGraphics.width = 125;
magicGraphics.height = 125;
self.x = x;
self.y = y;
+ self.move = function () {
+ if (self.moveEnabled) {
+ var santaX = self.gameInstance.santa && self.gameInstance.santa.santaGraphics ? self.gameInstance.santa.santaGraphics.x : 2048;
+ var santaY = self.gameInstance.santa && self.gameInstance.santa.santaGraphics ? self.gameInstance.santa.santaGraphics.y : 2732;
+ var santaWidth = self.gameInstance.santa && self.gameInstance.santa.santaGraphics ? self.gameInstance.santa.santaGraphics.width : 0;
+ var magicWidth = magicGraphics ? magicGraphics.width : 0;
+ var dx = santaX - self.x;
+ var dy = santaY - self.y;
+ var speed = 10;
+ if (dx == 0 || dy == 0) {
+ self.gameInstance.triggerGameOver();
+ } else if (self.x < 0 || self.x > 2048 || self.y < 0 || self.y > 2732) {
+ self.gameInstance.activeMagicCount--;
+ self.destroy();
+ }
+ }
+ };
self.on('down', function () {
LK.setScore(LK.getScore() + 2);
LK.gui.topCenter.children[0].setText(LK.getScore().toString());
var tingText = new Text2('Ting!', {
@@ -521,15 +538,15 @@
LK.on('tick', function () {
santa.move();
for (var i = 0; i < self.children.length; i++) {
var child = self.children[i];
- if (typeof child.move === 'function') {
+ if (child instanceof Snowflake) {
child.move();
- if (child instanceof Magic) {
- self.checkMagicCollisionWithSanta(child);
- }
} else if (child instanceof Mistletoe) {
child.bob();
+ } else if (child instanceof Magic) {
+ child.move();
+ self.checkMagicCollisionWithSanta(child);
}
}
if (self.isGameOver) {
return;
over the shoulder santa firing a revolver Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d transparent christmas crosshair Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d 3rd person front view of a christmas town square with a starry sky Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Christmas sparkles png Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
circular christmas golden star pattern transparent png Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d christmas brick wall Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d opened christmas crate Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d diagonal christmas car or truck in snow Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a christmas poster showcasing miss santa clause Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a single white snowflake Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d stacked christmas winter tire Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d stacked christmas winter tire Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d christmas magical mistletoe Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d christmas 357 Magnum bullets Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d silhouette of a flying reindeer with a red glowy nose Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d christmas dark sparkles Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d christmas evil robot elf with a gun 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.
2d pile of gray and red nuts and bolts Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
transparent snow sphere. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
snd_pistol
Sound effect
snd_enemyshot
Sound effect
snd_obstacle
Sound effect
snd_messages
Sound effect
snd_ricochet
Sound effect
snd_reindeer
Sound effect
snd_mistletoe
Sound effect
snd_reindeershot
Sound effect
snd_mistletoeshot
Sound effect
snd_christmasmusic
Music
snd_reload
Sound effect
snd_blastwave
Sound effect