Code edit (4 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: stars is not defined' in or related to this line: 'for (var i = stars.length - 1; i >= 0; i--) {' Line Number: 401
User prompt
add the stars to the stars array and update them from game tick function.
User prompt
the stars should explode upwards in all directions and then drop down while they fade out and disappear
User prompt
whenever score increases, create a particle explosion of stars around the scorelabel
Code edit (1 edits merged)
Please save this source code
Code edit (7 edits merged)
Please save this source code
User prompt
in the handleButtons function, add a copy of the button clicked to the latest cakelayer added.
Code edit (8 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: button.parent.numChildren is not a function' in or related to this line: 'console.log('button.parent.children.length - 1: ' + button.parent.numChildren() - 1);' Line Number: 358
Code edit (1 edits merged)
Please save this source code
User prompt
show a scorelabel center top
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'Error: The supplied index is out of bounds' in or related to this line: 'button.parent.setChildIndex(button, button.parent.getChildIndex(latestCakeLayer) + 1);' Line Number: 356
User prompt
in handlebuttons, also move the pressed button to a layer above the latest cake layer.
Code edit (3 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: game.getChildren is not a function' in or related to this line: 'button.zIndex = game.getChildren().length;' Line Number: 350
Code edit (1 edits merged)
Please save this source code
User prompt
let all buttons call handlebuttons function in their on down handler.
User prompt
implement the handebuttons function according to the comments inside it.
Code edit (1 edits merged)
Please save this source code
Initial prompt
Copy Layer Cake Panic
===================================================================
--- original.js
+++ change.js
@@ -1,67 +1,17 @@
/****
* Classes
-****/
-var StrawberryButton = Container.expand(function () {
+****/
+var BlueberryButton = Container.expand(function () {
var self = Container.call(this);
- var buttonGraphic = self.attachAsset('strawberryButton', {
+ var buttonGraphic = self.attachAsset('blueberryButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.on('down', function (obj) {
handleButtons(self);
});
});
-var RaspberryButton = Container.expand(function () {
- var self = Container.call(this);
- var buttonGraphic = self.attachAsset('raspberryButton', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.on('down', function (obj) {
- handleButtons(self);
- });
-});
-var WhippedCreamButton = Container.expand(function () {
- var self = Container.call(this);
- var buttonGraphic = self.attachAsset('whippedCreamButton', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.on('down', function (obj) {
- handleButtons(self);
- });
-});
-var MangoButton = Container.expand(function () {
- var self = Container.call(this);
- var buttonGraphic = self.attachAsset('mangoButton', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.on('down', function (obj) {
- handleButtons(self);
- });
-});
-var MouseButton = Container.expand(function () {
- var self = Container.call(this);
- var buttonGraphic = self.attachAsset('mouseButton', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.on('down', function (obj) {
- handleButtons(self);
- });
-});
-var FishButton = Container.expand(function () {
- var self = Container.call(this);
- var buttonGraphic = self.attachAsset('fishButton', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.on('down', function (obj) {
- handleButtons(self);
- });
-});
// CakeLayer class
var CakeLayer = Container.expand(function () {
var self = Container.call(this);
var layerGraphic = self.attachAsset('cakeLayer', {
@@ -69,9 +19,9 @@
anchorY: 0.5
});
self.speed = 3;
self.startY = self.y;
- self.targetY = 0; //2500;
+ self.targetY = 0;
self.tweenStartTime = LK.ticks;
self.tweening = false;
self.inPlace = false;
self.move = function () {
@@ -113,26 +63,48 @@
self.move = function () {
self.y += self.speed;
};
});
-// Table class
-var Table = Container.expand(function () {
+var FishButton = Container.expand(function () {
var self = Container.call(this);
- var tableGraphic = self.attachAsset('table', {
+ var buttonGraphic = self.attachAsset('fishButton', {
anchorX: 0.5,
anchorY: 0.5
});
+ self.on('down', function (obj) {
+ handleButtons(self);
+ });
});
-var BlueberryButton = Container.expand(function () {
+var FrogButton = Container.expand(function () {
var self = Container.call(this);
- var buttonGraphic = self.attachAsset('blueberryButton', {
+ var buttonGraphic = self.attachAsset('frogButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.on('down', function (obj) {
handleButtons(self);
});
});
+var MangoButton = Container.expand(function () {
+ var self = Container.call(this);
+ var buttonGraphic = self.attachAsset('mangoButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.on('down', function (obj) {
+ handleButtons(self);
+ });
+});
+var MouseButton = Container.expand(function () {
+ var self = Container.call(this);
+ var buttonGraphic = self.attachAsset('mouseButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.on('down', function (obj) {
+ handleButtons(self);
+ });
+});
var NutellaButton = Container.expand(function () {
var self = Container.call(this);
var buttonGraphic = self.attachAsset('nutellaButton', {
anchorX: 0.5,
@@ -151,29 +123,70 @@
self.on('down', function (obj) {
handleButtons(self);
});
});
-var FrogButton = Container.expand(function () {
+var RaspberryButton = Container.expand(function () {
var self = Container.call(this);
- var buttonGraphic = self.attachAsset('frogButton', {
+ var buttonGraphic = self.attachAsset('raspberryButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.on('down', function (obj) {
handleButtons(self);
});
});
+var StrawberryButton = Container.expand(function () {
+ var self = Container.call(this);
+ var buttonGraphic = self.attachAsset('strawberryButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.on('down', function (obj) {
+ handleButtons(self);
+ });
+});
+// Table class
+var Table = Container.expand(function () {
+ var self = Container.call(this);
+ var tableGraphic = self.attachAsset('table', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+});
+var WhippedCreamButton = Container.expand(function () {
+ var self = Container.call(this);
+ var buttonGraphic = self.attachAsset('whippedCreamButton', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.on('down', function (obj) {
+ handleButtons(self);
+ });
+});
/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
backgroundColor: 0x87ceeb // Init game with sky blue background
});
/****
* Game Code
-****/
+****/
+var scoreLabel = new Text2('Score: 0', {
+ size: 100,
+ fill: "#ffffff",
+ align: "center"
+});
+scoreLabel.x = game.width / 2;
+scoreLabel.y = 50;
+scoreLabel.anchor.set(0.5, 0);
+LK.gui.top.addChild(scoreLabel);
+// Update score label in the game tick event
+LK.on('tick', function () {
+ scoreLabel.setText('Score: ' + LK.getScore());
+});
function shuffleArray(array) {
for (var i = array.length - 1; i > 0; i--) {
var j = Math.floor(Math.random() * (i + 1));
var temp = array[i];
@@ -211,9 +224,9 @@
// Add background image
function shakeScreen(intensity, shakes) {
var shakeCount = 0;
var maxShakes = shakes || 10;
- var shakeAmount = 10; //intensity;
+ var shakeAmount = 10;
var shakeInterval = LK.setInterval(function () {
game.x += Math.random() * shakeAmount / 2 - shakeAmount / 4;
game.y += Math.random() * shakeAmount - shakeAmount / 2;
shakeCount++;
a dark wooden kitchen table with a serving plate.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A bakery wall with shelves full of cakes, toppings, berries. Rich game illustration style.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A swirl of delicious whipped cream. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A small pile of delicious blueberries. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A few delicious red raspberries, cleaned.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Lush, mature strawberries, cleaned and slices and ready for use in bakery or for decoration.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A little green frog. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A cute little goldfish. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A golden star.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A pile of pieces of milk chocolate. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.