Code edit (7 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'toString')' in or related to this line: 'mulText.setText('x' + newVal.toString());' Line Number: 176
User prompt
Fix Bug: 'ReferenceError: valText is not defined' in or related to this line: 'valText.anchor.set(0.5, 0.5);' Line Number: 173
Code edit (3 edits merged)
Please save this source code
User prompt
scorelabels should fly off in a random upwards direction instead of just up.
Code edit (1 edits merged)
Please save this source code
User prompt
add all created scorelabels to the scoreLabels array on creation.
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'update')' in or related to this line: 'self.scoreLabel.update();' Line Number: 323
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'update')' in or related to this line: 'self.scoreLabel.update();' Line Number: 323
Code edit (1 edits merged)
Please save this source code
User prompt
call the scorelabel's update method in the on tick loop, or in ball update
User prompt
remember to update the scorelabel, if it's present.
User prompt
when the player hits a platform or powerup and gets a score increase, show the number on screen as a little textlabel that drifts away and self-destroys after a brief moment.
Initial prompt
Copy Super Bounce
===================================================================
--- original.js
+++ change.js
@@ -1,16 +1,38 @@
/****
* Classes
****/
+var ScoreLabel = Container.expand(function (scoreValue, posX, posY) {
+ var self = Container.call(this);
+ var scoreText = new Text2(scoreValue.toString(), {
+ size: 75,
+ fill: "#ffffff"
+ });
+ scoreText.anchor.set(0.5, 0.5);
+ self.addChild(scoreText);
+ self.x = posX;
+ self.y = posY;
+ // Animation for the score label to drift upwards and fade out
+ var driftFrames = 60;
+ self.update = function () {
+ if (driftFrames > 0) {
+ self.y -= 2;
+ scoreText.alpha -= 1 / driftFrames;
+ driftFrames--;
+ } else {
+ self.destroy();
+ }
+ };
+});
/*
TODO:
--------------------
Bugs:
The red platforms have to be really shining up in red, dangerous looking.
Now that player graphic is bigger, it sometimes collides with platforms from below. Either adjust size, spacing
or jump height/logic.
-The platforms array grows in length over time. Try to remove deleted elements from it, but make backup first,
- because this is where the AI started optimizing to make the game page freeze last time.
+The platforms array grows in length over time. Try to remove deleted elements from it, but make backup first,
+because this is where the AI started optimizing to make the game page freeze last time.
Maybe remove the immunity from normal powerups, it's confusing.
Show points when player hits platform or gets powerup.
---------------------
Interface/graphics:
@@ -346,15 +368,21 @@
//self.velocity.x *= -1;
//platform.alpha = 0.2;
platform.alpha = 0;
LK.setScore(LK.getScore() + 1);
+ // Create and display score label
+ var scoreLabel = new ScoreLabel(1, self.x, self.y);
+ game.addChild(scoreLabel);
if (platform.powerup == true) {
//self.velocity.y = 50;
self.velocity.y = platform.velocityBoost;
//self.immunity = 10;
self.immunity = platform.immunityBoost;
//LK.setScore(LK.getScore() + 10);
LK.setScore(LK.getScore() + platform.scoreBoost);
+ // Create and display score label
+ var scoreLabel = new ScoreLabel(platform.scoreBoost, self.x, self.y);
+ game.addChild(scoreLabel);
if (platform.powerupType != "Follow") {
platform.destroy();
} else {
self.followers += 1;
@@ -401,10 +429,10 @@
/****
* Game Code
****/
-// Initialize background graphic asset
// Create background graphic and add it to the game
+// Initialize background graphic asset
var backgroundGraphic = game.addChild(LK.getAsset('background', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
@@ -606,9 +634,11 @@
platforms.forEach(function (platform) {
if (platform.update) {
platform.update();
}
- if (platform.y < -900) {
+ if (platform instanceof ScoreLabel) {
+ platform.update();
+ } else if (platform.y < -900) {
platform.y += rowAmount * 300;
platform.row += rowAmount;
// Only randomize normal platforms, not sidebarriers.
if (platform.height < 100) {
A happy blue elephant.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
erase.
Make the bird sit inside a birdcage.
Three green arrows pointing down.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A sad little bluebird sitting down.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A happy little bluebird flying.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A happy little green bird flying.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A lush jungle scenery with huge old trees covered in vines and overwrowth, blue sky and forested mountains in the background.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A dark wooden message board with vines and jungle moss growing on top.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A happy little blue elephant, looking scared, facing the viewer, legs flailing as it falls through the air.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A delicious peanut.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
delete