Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of null (reading 'nameDisplay')' in this line: 'self.parent.nameDisplay.updateName(randomName);' Line Number: 144
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'updateName')' in this line: 'self.nameDisplay.updateName(randomName);' Line Number: 144
User prompt
create a text box at x=1024 y=100 that displays a randomly selected name from name store each time displaygraphic changes
User prompt
Fix Bug: 'Uncaught TypeError: nameText.setText is not a function' in this line: 'nameText.setText(randomName);' Line Number: 137
User prompt
add text on top of scroll. Display a randomly selected name from nameStorage when displaygraphic is updated
User prompt
create a storage array to store a random mix of 50 boy and girls names. do not change any other code
Code edit (7 edits merged)
Please save this source code
User prompt
add falling snowflakes to screen
User prompt
Fix Bug: 'Uncaught ReferenceError: newImage is not defined' in this line: 'self.addChild(newImage);' Line Number: 220
Code edit (3 edits merged)
Please save this source code
User prompt
Add image at x = 1024 and y = 100
Code edit (1 edits merged)
Please save this source code
User prompt
move presentdisplay 50 to the right and 50 down
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught TypeError: presentTypeDisplay is not a constructor' in this line: 'var presentTypeDisplay = self.addChild(new presentTypeDisplay());' Line Number: 219
Code edit (11 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught ReferenceError: PresentTypeDisplay is not defined' in this line: 'var presentTypeDisplay = self.addChild(new PresentTypeDisplay());' Line Number: 219
Code edit (1 edits merged)
Please save this source code
User prompt
move rotating background tick to game
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught Error: [object Object]addChildAt: The index 2 supplied is out of bounds 1' in this line: 'self.addChildAt(background, 2);' Line Number: 214
User prompt
Fix Bug: 'Uncaught Error: [object Object]addChildAt: The index 1 supplied is out of bounds 0' in this line: 'self.addChildAt(rotatingBackground, 1);' Line Number: 212
Code edit (1 edits merged)
Please save this source code
User prompt
define background out side of game
===================================================================
--- original.js
+++ change.js
@@ -83,8 +83,25 @@
presentSpeedFactor: 3.5,
bounceFactor: 0.8,
gravity: 0.2
}];
+var NameDisplay = Container.expand(function () {
+ var self = Container.call(this);
+ self.nameText = new Text2('', {
+ size: 100,
+ fill: "#ffffff",
+ anchor: {
+ x: 0.5,
+ y: 0.5
+ }
+ });
+ self.nameText.x = 1024;
+ self.nameText.y = 100;
+ LK.gui.addChild(self.nameText);
+ self.updateName = function (name) {
+ self.nameText.setText(name);
+ };
+});
var Background = Container.expand(function () {
var self = Container.call(this);
var background = self.createAsset('background', 'Background Image', 0, 0);
background.width = 2048;
@@ -118,33 +135,14 @@
var presentTypeIndex = Math.floor(Math.random() * presentTypesCount);
var displayGraphic = self.createAsset(presentTypes[presentTypeIndex], presentTypes[presentTypeIndex] + ' Graphics', -0.2, -0.2);
displayGraphic.scale.x = 1.5;
displayGraphic.scale.y = 1.5;
- if (self.children.length > 1) {
+ if (self.children.length > 0) {
self.removeChildAt(0);
}
- var nameText;
- if (self.children.length === 1 && self.children[0] instanceof Text2) {
- nameText = self.children[0];
- } else {
- nameText = new Text2('', {
- size: 100,
- fill: '#000000',
- anchor: {
- x: 0.5,
- y: 0.5
- }
- });
- self.addChild(nameText);
- }
- if (self.children.length === 0) {
- self.addChild(nameText);
- }
- var randomName = nameStorage[Math.floor(Math.random() * nameStorage.length)];
- nameText.setText(randomName);
- nameText.x = displayGraphic.x;
- nameText.y = displayGraphic.y - displayGraphic.height / 2 - 50;
self.addChild(displayGraphic);
+ var randomName = nameStorage[Math.floor(Math.random() * nameStorage.length)];
+ self.nameDisplay.updateName(randomName);
};
self.setRandomPresentTypeIndex();
LK.setInterval(self.setRandomPresentTypeIndex, (Math.random() * (9 - 3) + 3) * 1000);
});
@@ -239,9 +237,11 @@
var scroll = self.createAsset('newImageAsset', 'Scroll', 0.5, 0.5);
scroll.x = 500;
scroll.y = 220;
self.addChild(scroll);
+ var nameDisplay = new NameDisplay();
var presentDisplay = self.addChild(new presentTypeDisplay());
+ presentDisplay.nameDisplay = nameDisplay;
presentTypeDisplay.x = 800;
presentTypeDisplay.y = 350;
var santaSack = new SantaSack();
self.addChild(santaSack);
basic snowflake. white Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
open top of Santa's sack. wrapped presents with ribbons and box, vivid colours, candy canes Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
close up of a Snow covered roof, Winter scene, star lit night sky, brick chimbly on right hand side, Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
gift wrapped box, vivid colours. with bow on top Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
gift wrapped box, vivid colours. with bow on top 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.
stary night sky.dark blue. no land. only sky 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.
gift wrapped box, vivid colours. with bow on top 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. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
gift wrapped box, vivid colours. with bow on top 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.
gift wrapped box, vivid colours. with bow on top 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.
Candy cane, vivid colours. with bow on top 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.
gift wrapped box, vivid colours. with bow on top 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.
gift wrapped box, vivid colours. with bow on top 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.
old paper scroll, blank with no writing, Single Game Texture. In-Game asset. 2d. transparent Blank background. High contrast. No shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
rudolf the red nose raindeer Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
gift wrapped box, bright colours. with bow on top Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. Single Game Texture.
gift wrapped box, bright light colours. with bow on top Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows. Single Game Texture.
Santa's sleigh with a team of reindeer moving across a star light sky. 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.