Code edit (1 edits merged)
Please save this source code
User prompt
move left right and center messages 300 pixels higher
Code edit (1 edits merged)
Please save this source code
User prompt
dime left center and right messages
User prompt
left center and right messages should disappear if lander crashes or players moves to level 2
User prompt
show center left and right messages on game start
User prompt
on game start add 3 messages. on the left side it should read: left. center: center. right: right.
User prompt
create 3 messages. right zone, center zone and left zone, that will be displayed between the dotted lines respectively. they will also behave the same way as the dotted line.
User prompt
create 3 messages that will have the same behaviour as the dotted line.
User prompt
add alpha of 0.5 to the dotted line
User prompt
dotted line should dissapear if lander crashe or if player moves to level 2
User prompt
double the space between dots
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'set')' in this line: 'leftMessage.anchor.set(0.5, 0.5);' Line Number: 454
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'set')' in this line: 'leftMessage.anchor.set(0.5, 0.5);' Line Number: 453
User prompt
Fix Bug: 'Uncaught TypeError: Point is not a constructor' in this line: 'self.textObject.anchor = new Point(0.5, 0.5);' Line Number: 12
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'set')' in this line: 'leftMessage.anchor.set(0.5, 0.5);' Line Number: 453
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'set')' in this line: 'leftMessage.anchor.set(0.5, 0.5);' Line Number: 453
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'set')' in this line: 'leftMessage.anchor.set(0.5, 0.5);' Line Number: 452
User prompt
left center and right messages should flicker
User prompt
make sure left center and right messaes have a dim effect on them
User prompt
move center left and right messages in front of background on the z axis
User prompt
move center left and right messages behind lander on z axis
Code edit (2 edits merged)
Please save this source code
User prompt
Fix Bug: 'ReferenceError: rightThruster is not defined' in this line: 'rightThruster.visible = false;' Line Number: 88
User prompt
Fix Bug: 'ReferenceError: rightThruster is not defined' in this line: 'rightThruster.visible = false;' Line Number: 88
===================================================================
--- original.js
+++ change.js
@@ -1,7 +1,23 @@
/****
* Classes
****/
+var FlickerText = Container.expand(function () {
+ var self = Container.call(this);
+ self.textObject = null;
+ self.flickerRate = 30;
+ self.visible = true;
+ self.createFlickerText = function (text, options) {
+ self.textObject = new Text2(text, options);
+ self.addChild(self.textObject);
+ };
+ self.update = function () {
+ if (LK.ticks % self.flickerRate === 0) {
+ self.visible = !self.visible;
+ }
+ self.textObject.visible = self.visible;
+ };
+});
var CrashedLander = Container.expand(function () {
var self = Container.call(this);
var crashedLanderGraphics = self.createAsset('crashedlander', 'Crashed Lander', 0.5, 0.5);
self.destroyAfterOneSecond = function () {
@@ -423,34 +439,37 @@
platform.x = 1024; // Center horizontally
platform.y = 2632; // Place at the bottom
// Display start messages
-var leftMessage = new Text2('Left\nThruster', {
+var leftMessage = game.addChild(new FlickerText());
+leftMessage.createFlickerText('Left\nThruster', {
size: 100,
fill: '#ffffff',
- align: 'center',
- alpha: 0.3
+ align: 'center'
});
+leftMessage.flickerRate = 30;
leftMessage.anchor.set(0.5, 0.5);
leftMessage.x = 2048 / 3 / 2;
leftMessage.y = 1166;
game.addChild(leftMessage);
-var centerMessage = new Text2('Center\nThruster', {
+var centerMessage = game.addChild(new FlickerText());
+centerMessage.createFlickerText('Center\nThruster', {
size: 100,
fill: '#ffffff',
- align: 'center',
- alpha: 0.3
+ align: 'center'
});
+centerMessage.flickerRate = 30;
centerMessage.anchor.set(0.5, 0.5);
centerMessage.x = 1024;
centerMessage.y = 1166;
game.addChild(centerMessage);
-var rightMessage = new Text2('Right\nThruster', {
+var rightMessage = game.addChild(new FlickerText());
+rightMessage.createFlickerText('Right\nThruster', {
size: 100,
fill: '#ffffff',
- align: 'center',
- alpha: 0.3
+ align: 'center'
});
+rightMessage.flickerRate = 30;
rightMessage.anchor.set(0.5, 0.5);
rightMessage.x = 2048 - 2048 / 3 / 2;
rightMessage.y = 1166;
game.addChild(rightMessage);
@@ -524,8 +543,15 @@
}
return;
}
if (!isGameOver) {
+ // Update all FlickerText instances
+ game.children.filter(function (child) {
+ return child instanceof FlickerText;
+ }).forEach(function (flickerText) {
+ flickerText.update();
+ });
+
// Update all asteroids
asteroids = game.children.filter(function (child) {
return child instanceof Asteroid;
});