Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Use 5 different bell chime sounds
User prompt
Play a bell chime when you touch a bell
User prompt
Migrate to the latest version of LK
User prompt
Also submit scores to LK.setScore when scores are updated
User prompt
Update code to use LK scote
User prompt
add 8 bells when the game starts
User prompt
set speed y to -15 when hitting a bell
User prompt
Half the y modifier when spawning a new bell
Code edit (1 edits merged)
Please save this source code
User prompt
Add 500px to targetParallaxValue
Code edit (2 edits merged)
Please save this source code
User prompt
slowly increase bellSpeed each time you collect a bell
User prompt
in ScoreText set font weight to 400.
User prompt
Start score text scale at zero in ScoreText, then quickly scale to a max of one
User prompt
Update score text move method, such that a score first animates in from scale zero, then stays on screen for a bit and then scales down again together with alpha
User prompt
do not move y in score text move method
User prompt
when creating a particle, just pass p
Code edit (1 edits merged)
Please save this source code
User prompt
Subtract 4 from score y speed rather than 2
User prompt
On score text in ScoreText label add a 10px black outline
User prompt
Set score text text2 node, in ScoreText class, to size to 120. Sweet weight:200 and remove the drop shadow
User prompt
Set score text text2 node size to 120. Sweet weight:200 and remove the drop shadow
User prompt
add score texts to the particle array
===================================================================
--- original.js
+++ change.js
@@ -1,35 +1,34 @@
/****
* Classes
-****/
-var ScoreText = Container.expand(function (score, x, y) {
+****/
+var Bell = Container.expand(function (score) {
var self = Container.call(this);
- self.x = x;
- self.y = y;
- var scoreText = new Text2(score.toString(), {
- size: 120,
- fill: '#ffffff',
- weight: 400,
- stroke: '#000000',
- strokeThickness: 10
+ self.score = score;
+ var bellBackground = self.attachAsset('bellBackground', {
+ anchorX: 0.5,
+ anchorY: 0.5
});
- scoreText.anchor.set(.5, .5);
- scoreText.scale.set(0, 0);
- self.addChild(scoreText);
- var scaleIncrease = 0.05;
- LK.on('tick', function () {
- if (scoreText.scale.x < 1) {
- scoreText.scale.x += scaleIncrease;
- scoreText.scale.y += scaleIncrease;
- }
+ self.addChild(bellBackground);
+ var bellGraphics = self.attachAsset('bell', {
+ anchorX: 0.5,
+ anchorY: 0.5
});
- self.move = function () {
- self.alpha -= 0.02;
- if (self.alpha <= 0) {
- self.destroy();
- }
+ bellGraphics.blendMode = 1;
+ self.addChild(bellGraphics);
+ self._move_migrated = function () {
+ self.y += self.parent.parent.bellSpeed;
};
});
+var ParallaxLayer = Container.expand(function (speed) {
+ var self = Container.call(this);
+ self.actualY = 0;
+ self.speed = typeof speed !== 'undefined' ? speed : 1;
+ self.setParallaxY = function (y) {
+ self.actualY = y * self.speed;
+ self.y = self.actualY;
+ };
+});
var Particle = Container.expand(function (x, y, index) {
var self = Container.call(this, x, y);
self.index = index;
var particleGraphics = self.attachAsset('particle', {
@@ -40,9 +39,9 @@
self.y = y;
var angle = index % 20 * (Math.PI * 2 / 20);
self.fixedSpeed = 30;
self.angle = angle;
- self.move = function () {
+ self._move_migrated = function () {
self.fixedSpeed *= 0.95;
self.x += Math.cos(self.angle) * self.fixedSpeed;
self.y += Math.sin(self.angle) * self.fixedSpeed;
self.cachedAlpha = (self.cachedAlpha || 3) - 0.04;
@@ -51,35 +50,8 @@
self.destroy();
}
};
});
-var ParallaxLayer = Container.expand(function (speed) {
- var self = Container.call(this);
- self.actualY = 0;
- self.speed = typeof speed !== 'undefined' ? speed : 1;
- self.setParallaxY = function (y) {
- self.actualY = y * self.speed;
- self.y = self.actualY;
- };
-});
-var Bell = Container.expand(function (score) {
- var self = Container.call(this);
- self.score = score;
- var bellBackground = self.attachAsset('bellBackground', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.addChild(bellBackground);
- var bellGraphics = self.attachAsset('bell', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- bellGraphics.blendMode = 1;
- self.addChild(bellGraphics);
- self.move = function () {
- self.y += self.parent.parent.bellSpeed;
- };
-});
var Player = Container.expand(function () {
var self = Container.call(this);
self.targetX = self.x;
var playerGraphics = self.attachAsset('player', {
@@ -93,9 +65,9 @@
self.hasJumped = true;
}
};
self.fall = function () {};
- self.update = function () {
+ self._update_migrated = function () {
var distance = Math.abs(self.x - self.targetX);
var speed = Math.max(1, distance / 25);
if (self.x < self.targetX) {
self.x += Math.min(speed, self.targetX - self.x);
@@ -107,8 +79,36 @@
self.y += self.speedy;
self.speedy += 0.28;
};
});
+var ScoreText = Container.expand(function (score, x, y) {
+ var self = Container.call(this);
+ self.x = x;
+ self.y = y;
+ var scoreText = new Text2(score.toString(), {
+ size: 120,
+ fill: '#ffffff',
+ weight: 400,
+ stroke: '#000000',
+ strokeThickness: 10
+ });
+ scoreText.anchor.set(.5, .5);
+ scoreText.scale.set(0, 0);
+ self.addChild(scoreText);
+ var scaleIncrease = 0.05;
+ LK.on('tick', function () {
+ if (scoreText.scale.x < 1) {
+ scoreText.scale.x += scaleIncrease;
+ scoreText.scale.y += scaleIncrease;
+ }
+ });
+ self._move_migrated = function () {
+ self.alpha -= 0.02;
+ if (self.alpha <= 0) {
+ self.destroy();
+ }
+ };
+});
var Snowflake = Container.expand(function () {
var self = Container.call(this);
var flakeGraphics = self.attachAsset('snowflake', {
anchorX: 0.5,
@@ -116,9 +116,9 @@
});
self.speedy = Math.random() * 2 + 1;
self.speedx = Math.random() * 1 - 0.5;
self.rotationSpeed = Math.random() * 0.05 - 0.025;
- self.move = function () {
+ self._move_migrated = function () {
self.y += self.speedy;
self.scale.set(self.speedy / 3, self.speedy / 3);
self.x += self.speedx;
self.rotation += self.rotationSpeed;
@@ -134,16 +134,16 @@
});
/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
-****/
+****/
game.bellSpeed = 5;
game.bellSpeedIncreaseFactor = 0.001;
game.totalTicks = 0;
game.layers = [];
@@ -218,9 +218,9 @@
dropShadowAngle: Math.PI / 6,
dropShadowDistance: 6
});
scoreTxt.anchor.set(.5, 0);
-LK.gui.topCenter.addChild(scoreTxt);
+LK.gui.top.addChild(scoreTxt);
var bells = [];
game.addBell = function () {
var lastBellY = bells.length > 0 ? bells[bells.length - 1].y : 2732;
var nextScore = bells.length > 0 ? bells[bells.length - 1].score + 1 : 1;
@@ -235,9 +235,9 @@
var player;
var scoreTxt;
var isGameOver = false;
LK.on('tick', function () {
- player.update();
+ player._update_migrated();
var targetParallaxValue = 1366 - player.y + 500;
var currentParallaxValue = foreground.actualY;
var parallaxDifference = targetParallaxValue - currentParallaxValue;
var parallaxSpeed = Math.max(1, Math.abs(parallaxDifference) / 10);
@@ -247,9 +247,9 @@
layer.setParallaxY(currentParallaxValue + Math.min(parallaxSpeed, targetParallaxValue - currentParallaxValue));
});
}
for (var i = 0; i < bells.length; i++) {
- bells[i].move();
+ bells[i]._move_migrated();
if (player.intersects(bells[i])) {
player.speedy = -15;
player.hasJumped = true;
var newScore = LK.getScore() + bells[i].score;
@@ -277,9 +277,9 @@
if (player.y + foreground.y > 2732) {
isGameOver = true;
}
game.particles.forEach(function (particle) {
- particle.move();
+ particle._move_migrated();
if (particle.alpha <= 0) {
var index = game.particles.indexOf(particle);
if (index > -1) {
game.particles.splice(index, 1);
@@ -292,15 +292,15 @@
LK.effects.flashScreen(0xffffff, 1000);
LK.showGameOver();
}
});
-game.on('down', function (obj) {
- var event = obj.event;
- var pos = event.getLocalPosition(game);
+game.on('down', function (x, y, obj) {
+ var event = obj;
+ var pos = game.toLocal(event.global);
player.targetX = pos.x;
player.jump();
});
-game.on('move', function (obj) {
- var event = obj.event;
- var pos = event.getLocalPosition(game);
+game.on('move', function (x, y, obj) {
+ var event = obj;
+ var pos = game.toLocal(event.global);
player.targetX = pos.x;
});
\ No newline at end of file
Tree line of snowy pine trees. Cartoon. Black background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Mountain valley with snowy trees. Scenic view. Nighttime. Cartoon. Black background. New moon Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Background mountains, nighttime, snow topped Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
2d platform snowy ground. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Cute cartoon rabbit, jumping upwards facing camera. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Starry night sky, northern lights, looking up. Cartoon style. Above clouds Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Single White Christmas bell. White decorations. Cartoon. Outline Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
White Simple Cartoon snowflake Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.