User prompt
updatePlayerIcons doesn't work because in the caller funciton self is refering to the HorizontalLine not the game. fix this
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'scale')' in this line: 'player1Icon.scale.set(currentPlayer === 1 ? 1.2 : 0.8);' Line Number: 57
User prompt
update updatePlayerIcons to make it dependency free
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'scale')' in this line: 'gameInstance.player1Icon.scale.set(currentPlayer === 1 ? 1.2 : 0.8);' Line Number: 58
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'scale')' in this line: 'gameInstance.player1Icon.scale.set(currentPlayer === 1 ? 1.2 : 0.8);' Line Number: 58
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'scale')' in this line: 'gameInstance.player1Icon.scale.set(currentPlayer === 1 ? 1.2 : 0.8);' Line Number: 58
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'scale')' in this line: 'gameInstance.player1Icon.scale.set(currentPlayer === 1 ? 1.2 : 0.8);' Line Number: 58
User prompt
updatePlayerIcons everywhere where possible
User prompt
factorise the code responsible of updating players icons in an idependant function
Code edit (1 edits merged)
Please save this source code
User prompt
reduce inital lines alpha
Code edit (1 edits merged)
Please save this source code
User prompt
tint player one lines in red and player 2 lines in green
User prompt
tint player 1 in red, and player 2 in green
User prompt
Fix Bug: 'ReferenceError: player1Icon is not defined' in this line: 'player1Icon.scale.set(currentPlayer === 1 ? 1.2 : 1);' Line Number: 35
User prompt
the scale of current player should change each turn
User prompt
make player icon a bit bigger when it's his turn
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'x')' in this line: 'hLine.x = dot.x;' Line Number: 73
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: currentPlayer is not defined' in this line: 'self.playerNumber = currentPlayer;' Line Number: 29
User prompt
alternate the player after each click
User prompt
when a line is clicked, set the alpha to 1 and add a tint : blue for player one and red for player 2
User prompt
reduce the alpha of lines
Code edit (1 edits merged)
Please save this source code
var VerticalLine = Container.expand(function (playerNumber) { var self = Container.call(this); var lineGraphics = self.createAsset('lineVertical', 'Vertical Line Graphics', 0.5, 0); lineGraphics.alpha = 0.5; self.playerNumber = null; self.setLength = function (length) { lineGraphics.height = length; }; self.on('down', function () { if (self.playerNumber === null) { self.playerNumber = currentPlayer; lineGraphics.alpha = 1; lineGraphics.tint = currentPlayer === 1 ? 0xFF0000 : 0x00FF00; currentPlayer = currentPlayer === 1 ? 2 : 1; self.parent.player1Icon.scale.set(currentPlayer === 1 ? 1.2 : 0.8); self.parent.player2Icon.scale.set(currentPlayer === 2 ? 1.2 : 0.8); } }); return self; }); var HorizontalLine = Container.expand(function (playerNumber) { var self = Container.call(this); var lineGraphics = self.createAsset('lineHorizontal', 'Horizontal Line Graphics', 0, 0.5); lineGraphics.alpha = 0.5; self.playerNumber = null; self.setLength = function (length) { lineGraphics.width = length; }; self.on('down', function () { if (self.playerNumber === null) { self.playerNumber = currentPlayer; lineGraphics.alpha = 1; lineGraphics.tint = currentPlayer === 1 ? 0xFF0000 : 0x00FF00; currentPlayer = currentPlayer === 1 ? 2 : 1; self.parent.player1Icon.scale.set(currentPlayer === 1 ? 1.2 : 1); self.parent.player2Icon.scale.set(currentPlayer === 2 ? 1.2 : 1); } }); return self; }); var Dot = Container.expand(function () { var self = Container.call(this); var dotGraphics = self.createAsset('dot', 'Dot Graphics', .5, .5); self.connect = function () {}; }); var Square = Container.expand(function () { var self = Container.call(this); var squareGraphics = self.createAsset('square', 'Square Graphics', .5, .5); self.collectGift = function () {}; }); var PlayerIcon = Container.expand(function (playerNumber) { var self = Container.call(this); var iconAsset = playerNumber === 1 ? 'player1Icon' : 'player2Icon'; var playerIconGraphics = self.createAsset(iconAsset, 'Player ' + playerNumber + ' Icon', 0.5, 0.5); playerIconGraphics.tint = playerNumber === 2 ? 0x00FF00 : playerIconGraphics.tint; playerIconGraphics.tint = playerNumber === 1 ? 0xFF0000 : playerIconGraphics.tint; return self; }); var currentPlayer = 1; var Game = Container.expand(function () { var self = Container.call(this); self.player1Icon = self.addChild(new PlayerIcon(1)); self.player1Icon.x = 2048 * 0.25; self.player1Icon.y = 200; self.player1Icon.scale.set(1.2); self.player2Icon = self.addChild(new PlayerIcon(2)); self.player2Icon.x = 2048 * 0.75; self.player2Icon.y = 200; self.player2Icon.scale.set(1); var dots = []; var squares = []; var gifts = 0; var currentPlayer = 1; var boardSize = 6 * 300; var offsetX = (2048 - boardSize) / 2; var offsetY = (2732 - boardSize) / 2 + 150; for (var i = 0; i < 7; i++) { for (var j = 0; j < 7; j++) { var dot = new Dot(); dot.x = offsetX + i * 300; dot.y = offsetY + j * 300; dots.push(dot); if (i < 6) { var hLine = new HorizontalLine(); hLine.x = dot.x; hLine.y = dot.y; hLine.setLength(300); self.addChild(hLine); } if (j < 6) { var vLine = new VerticalLine(); vLine.x = dot.x; vLine.y = dot.y; vLine.setLength(300); self.addChild(vLine); } self.addChild(dot); } } dots.forEach(function (dot) { dot.on('down', function (obj) { var event = obj.event; var pos = event.getLocalPosition(self); }); }); LK.on('tick', function () { squares.forEach(function (square) { if (square.isComplete()) { gifts++; square.collectGift(); } }); }); });
===================================================================
--- original.js
+++ change.js
@@ -11,10 +11,10 @@
self.playerNumber = currentPlayer;
lineGraphics.alpha = 1;
lineGraphics.tint = currentPlayer === 1 ? 0xFF0000 : 0x00FF00;
currentPlayer = currentPlayer === 1 ? 2 : 1;
- self.parent.player1Icon.scale.set(currentPlayer === 1 ? 1.2 : 1);
- self.parent.player2Icon.scale.set(currentPlayer === 2 ? 1.2 : 1);
+ self.parent.player1Icon.scale.set(currentPlayer === 1 ? 1.2 : 0.8);
+ self.parent.player2Icon.scale.set(currentPlayer === 2 ? 1.2 : 0.8);
}
});
return self;
});
a b&w grinch icon Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
b&w smiling Santa Clauss' head icon Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a white christmas star. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
top face of a white gift. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.