Code edit (3 edits merged)
Please save this source code
Code edit (7 edits merged)
Please save this source code
User prompt
restore the first logo entrance code : ``` tween(logo, { x: 1024, y: 1366 }, { duration: 2000, easing: tween.elasticIn, onFinish: function onFinish() { isMoving = false; // Set the flag to false when the logo stops moving logoIn = true; } }); ```
User prompt
Ok. clean the code
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: corner is undefined' in or related to this line: 'corner.x = logo.x;' Line Number: 78
Code edit (1 edits merged)
Please save this source code
User prompt
in corners change 50 offset to 20
User prompt
in ` tween(logo, { x: isLogoIn ? logo.width / 2 : 1024, y: isLogoIn ? logo.height / 2 : 1366 } ` use a random corner instead of logo.width / 2, logo.height / 2
User prompt
in ` tween(logo, { x: isLogoIn ? logo.width / 2 : 1024, y: isLogoIn ? logo.height / 2 : 1366 } ` use a random corner
Code edit (3 edits merged)
Please save this source code
User prompt
fix x: isLogoIn ? -logo.width : 1024, y: isLogoIn ? -logo.height : 1366 to stay in screen boundaries
User prompt
update corners so the logo stays with screen boundaries
Code edit (1 edits merged)
Please save this source code
/**** 
* Plugins
****/ 
var tween = LK.import("@upit/tween.v1");
/**** 
* Classes
****/ 
// Logo class
var Logo = Container.expand(function () {
	var self = Container.call(this);
	var logoGraphics = self.attachAsset('logo', {
		anchorX: 0.5,
		anchorY: 0.5
	});
});
/**** 
* Initialize Game
****/ 
//<Write entity 'classes' with empty functions for important behavior here>
var game = new LK.Game({
	backgroundColor: 0x5D92B1 //Change background color to pastel dark blue
});
/**** 
* Game Code
****/ 
var logo = game.addChild(new Logo());
logo.x = -logo.width;
logo.y = -logo.height;
var logoIn = false; // Track the state of the logo (in or out)
var easingIndex = 0;
var easingFunctionsIn = [tween.linear, tween.easeIn, tween.elasticIn, tween.bounceIn];
var easingFunctionsInNames = ['linear', 'easeIn', 'elasticIn', 'bounceIn'];
var easingFunctionsOut = [tween.linear, tween.easeOut, tween.elasticOut, tween.bounceOut];
var easingFunctionsOutNames = ['linear', 'easeOut', 'elasticOut', 'bounceOut'];
var corners = [{
	x: logo.width / 2 + 20,
	y: logo.height / 2 + 20
},
// Top left
{
	x: 2048 - logo.width / 2 - 20,
	y: logo.height / 2 + 20
},
// Top right
{
	x: logo.width / 2 + 20,
	y: 2732 - logo.height / 2 - 20
},
// Bottom left
{
	x: 2048 - logo.width / 2 - 20,
	y: 2732 - logo.height / 2 - 20
} // Bottom right
];
var isMoving = false; // Flag to check if the logo is moving
game.down = function (x, y, obj) {
	if (isMoving) {
		return;
	} // If the logo is moving, ignore the click
	animateLogo(logoIn);
	//easingText.setText(logoIn ? easingFunctionsInNames[easingIndex % easingFunctionsIn.length] : easingFunctionsOutNames[easingIndex % easingFunctionsOut.length]);
};
function animateLogo(isLogoIn) {
	isMoving = true; // Set the flag to true when the logo starts moving
	var corner;
	if (isLogoIn) {
		// If logo is in, animate it out
		selectedEasing = easingFunctionsOut[easingIndex % easingFunctionsOut.length];
		easingText.setText(easingFunctionsOutNames[easingIndex % easingFunctionsOut.length]);
		// Randomly select a corner for the logo to appear
		corner = corners[Math.floor(Math.random() * corners.length)];
	} else {
		// If logo is out, animate it in
		selectedEasing = easingFunctionsIn[easingIndex % easingFunctionsIn.length];
		easingText.setText(easingFunctionsInNames[easingIndex % easingFunctionsIn.length]);
		corner = corners[Math.floor(Math.random() * corners.length)];
	}
	tween(logo, {
		x: isLogoIn ? corner.x : 1024,
		y: isLogoIn ? corner.y : 1366
	}, {
		duration: 2000,
		easing: selectedEasing,
		onFinish: function onFinish() {
			isMoving = false; // Set the flag to false when the logo stops moving
			if (isLogoIn) {
				animateLogo(false);
			} else {
				easingIndex++;
			}
		}
	});
	logoIn = !isLogoIn;
}
// Add a text 'Easing' in bottom center
var easingText = new Text2('Easing', {
	size: 150,
	fill: 0x0000FF
});
easingText.anchor.set(0.5, 1); // Sets anchor to the center of the bottom edge of the text.
easingText.x = 1024; // Center of the game width
easingText.y = 2632; // Bottom of the game height
easingText.tint = 0xFF0000;
game.addChild(easingText);
animateLogo(true); ===================================================================
--- original.js
+++ change.js
@@ -97,12 +97,12 @@
 }
 // Add a text 'Easing' in bottom center
 var easingText = new Text2('Easing', {
 	size: 150,
-	fill: 0xFFFFFF
+	fill: 0x0000FF
 });
 easingText.anchor.set(0.5, 1); // Sets anchor to the center of the bottom edge of the text.
 easingText.x = 1024; // Center of the game width
 easingText.y = 2632; // Bottom of the game height
-easingText.tint = 0xFFFFFF;
+easingText.tint = 0xFF0000;
 game.addChild(easingText);
 animateLogo(true);
\ No newline at end of file