Code edit (7 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'y')' in this line: 'scoreTxt.y = currentCard.y - currentCard.height / 2 - scoreTxt.height / 2;' Line Number: 121
User prompt
make sure score is centered on top of the car
User prompt
center score not matter the text size
Code edit (1 edits merged)
Please save this source code
User prompt
mvoe score 300 pixels lef
Code edit (1 edits merged)
Please save this source code
User prompt
center score in the top center. make sure anchor is set correclty
Code edit (1 edits merged)
Please save this source code
User prompt
Add '''Score:'' next to the score value
User prompt
show a copy of valuetext on the opposite corner of the card, and also turn it upside down.
User prompt
Make sure dislpayvalue is being shown int he card
User prompt
Replace some values visual respresentation. 11 should be J, 12 should be Q and 13 should be K.
User prompt
Value text x an y should be the upper left corner of the card
Code edit (1 edits merged)
Please save this source code
User prompt
remove value topleft
User prompt
value text should show on the top center of the card
Code edit (1 edits merged)
Please save this source code
User prompt
Move value 400 pixela.up
User prompt
Fix value anchor toe be displayed in the upper lwft corner of the card
User prompt
Move value to the upper left corner of the vard
User prompt
Fix message display anchor to be displayed in the bottom centwr
User prompt
Correcr or wrong should be in the bottom centwr
User prompt
Nextcard should also be in the center
User prompt
Card should be in the center of the screen. Fiz its anchor
var MessageDisplay = Container.expand(function () { var self = Container.call(this); var messageText = new Text2('', { size: 100, fill: '#ffffff', anchor: { x: 0.5, y: 0 } }); self.addChild(messageText); messageText.y = 2732 - messageText.height; self.showMessage = function (message) { messageText.setText(message); messageText.x = 2048 / 2 - messageText.width / 2; self.addChild(messageText); LK.setTimeout(function () { messageText.setText(''); }, 2000); }; }); var Card = Container.expand(function () { var self = Container.call(this); self.setSuit = function (suit) { self.suit = suit; var suitAsset = self.createAsset('suit_' + suit, 'Suit Asset', 0.5, 0.5); suitAsset.x = 0; suitAsset.y = 0; self.addChild(suitAsset); }; var cardGraphics = self.createAsset('card', 'Card Graphics', 0.5, 0.5); cardGraphics.anchor.set(0.5, 0.5); var valueText = new Text2('', { size: 100, fill: '#000000', anchor: { x: 0.5, y: 0 } }); valueText.anchor.set(0.5, 0.5); valueText.x = 0; valueText.y = 200; self.setValue = function (value) { self.value = value; valueText.setText(value.toString()); valueTextTopLeft.setText(value.toString()); }; self.addChild(valueText); var suitText = new Text2('', { size: 100, fill: '#000000', anchor: { x: 0.5, y: 1 } }); suitText.y = 0; self.addChild(suitText); self.setValue = function (value) { self.value = value; valueText.setText(value.toString()); }; self.value = 0; self.setValue = function (value) { self.value = value; valueText.setText(value.toString()); }; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.createAsset('player', 'Player Graphics', .5, .5); self.score = 0; self.updateScore = function (score) { self.score = score; }; }); var Game = Container.expand(function () { var self = Container.call(this); stage.on('up', function (obj) { var endY = obj.event.getLocalPosition(self).y; if (startY === null || endY === null) return; var swipeDirection = startY - endY; var guess = swipeDirection > 0 ? 'higher' : 'lower'; if (deck.length === 0) { LK.showGameOver(); return; } nextCard = deck.pop(); if (!nextCard) return; self.addChild(nextCard); nextCard.x = 2048 / 2; nextCard.y = 2732 / 2; var messageDisplay = self.addChild(new MessageDisplay()); var correctGuess = guess === 'higher' && nextCard.value > currentCard.value || guess === 'lower' && nextCard.value < currentCard.value; if (correctGuess) { player.updateScore(player.score + 1); self.updateScoreDisplay(player.score); LK.setScore(player.score); messageDisplay.showMessage('Correct!'); } else { messageDisplay.showMessage('Wrong!'); } currentCard.destroy(); currentCard = nextCard; nextCard = null; startY = null; }); var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff", anchor: { x: 1, y: .5 } }); scoreTxt.y = 50; LK.gui.topCenter.addChild(scoreTxt); self.updateScoreDisplay = function (score) { scoreTxt.setText(score.toString()); }; self.updateScoreDisplay(0); var deck = []; var player = self.addChild(new Player()); var currentCard = null; var nextCard = null; var suits = ['hearts', 'diamonds', 'clubs', 'spades']; for (var s = 0; s < suits.length; s++) { for (var i = 1; i <= 13; i++) { var card = new Card(); card.setValue(i); card.setSuit(suits[s]); deck.push(card); } } deck.sort(function () { return 0.5 - Math.random(); }); currentCard = deck[Math.floor(Math.random() * deck.length)]; var index = deck.indexOf(currentCard); deck.splice(index, 1); self.addChild(currentCard); currentCard.x = 2048 / 2; currentCard.y = 2732 / 2; player.x = 2048 / 2; player.y = 2732 / 2 + 200; var startY = null; stage.on('down', function (obj) { startY = obj.event.getLocalPosition(self).y; }); });
===================================================================
--- original.js
+++ change.js
@@ -39,9 +39,9 @@
}
});
valueText.anchor.set(0.5, 0.5);
valueText.x = 0;
- valueText.y = 0;
+ valueText.y = 200;
self.setValue = function (value) {
self.value = value;
valueText.setText(value.toString());
valueTextTopLeft.setText(value.toString());
Green casino baize. To be used as background. No shade. 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.
white rectangle flat. rounded corners. no background. no shadow. card shape.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.