Code edit (1 edits merged)
Please save this source code
User prompt
never mind, change bg color to pastel dark blue
User prompt
change 0x5D92B1 to paster green
User prompt
Please fix the bug: 'tween is not defined' in or related to this line: 'var easingFunctionsIn = [tween.linear, tween.easeIn, tween.elasticIn, tween.bounceIn];' Line Number: 30 ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
now at each logo move update the text with the name of current easing
User prompt
Please fix the bug: 'TypeError: randomEasing is undefined' in or related to this line: 'easingText.setText(randomEasing.name);' Line Number: 87
Code edit (1 edits merged)
Please save this source code
User prompt
create an array equivalent to easingFunctionsIn but with easing functions names as a strings
User prompt
create an new array equivalent to easingFunctionsIn but with easing functions names as strings
User prompt
Please fix the bug: 'TypeError: easing is not a function' in or related to this line: 'easingText.setText(randomEasing.name);' Line Number: 88
User prompt
Please fix the bug: 'TypeError: easing is not a function' in or related to this line: 'easingText.setText(randomEasing.name);' Line Number: 88
User prompt
Please fix the bug: 'TypeError: easing is not a function' in or related to this line: 'easingText.setText(randomEasing.name);' Line Number: 88
User prompt
Please fix the bug: 'TypeError: easing is not a function' in or related to this line: 'easingText.setText(randomEasing);' Line Number: 88
User prompt
Please fix the bug: 'TypeError: easing is not a function' in or related to this line: 'easingText.setText(randomEasing.name);' Line Number: 88
User prompt
Please fix the bug: 'TypeError: easing is not a function' in or related to this line: 'easingText.setText(randomEasing);' Line Number: 88
User prompt
create an new global variable easingFunctionsInNames equivalent to easingFunctionsIn but with easing functions names as strings
User prompt
create also easingFunctionsOutNames
User prompt
easingFunctionsOutNames and easingFunctionsInNames for setText
User prompt
now remove randomness (loop over easings)
User prompt
move easingIndex and corners to global scope
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'logo is undefined' in or related to this line: 'var corners = [{' Line Number: 40
Code edit (1 edits merged)
Please save this source code
User prompt
prevent click while move isn't finished
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: 0x000000 //Init game with black background
});
/****
* Game Code
****/
var logoIn = false; // Track the state of the logo (in or out)
var easingFunctionsIn = [tween.linear, tween.easeIn, tween.elasticIn, tween.bounceIn];
var easingFunctionsOut = [tween.linear, tween.easeOut, tween.elasticOut, tween.bounceOut];
game.down = function (x, y, obj) {
var randomEasing;
function animateLogo(isLogoIn) {
var randomEasing;
if (!isLogoIn) {
// If logo is out, animate it in
// Randomly select a corner for the logo to appear
var corners = [{
x: -logo.width,
y: -logo.height
},
// Top left
{
x: 2048 + logo.width,
y: -logo.height
},
// Top right
{
x: -logo.width,
y: 2732 + logo.height
},
// Bottom left
{
x: 2048 + logo.width,
y: 2732 + logo.height
} // Bottom right
];
var corner = corners[Math.floor(Math.random() * corners.length)];
logo.x = corner.x;
logo.y = corner.y;
randomEasing = easingFunctionsIn[Math.floor(Math.random() * easingFunctionsIn.length)];
} else {
// If logo is in, animate it out
randomEasing = easingFunctionsOut[Math.floor(Math.random() * easingFunctionsOut.length)];
}
tween(logo, {
x: isLogoIn ? -logo.width : 1024,
y: isLogoIn ? -logo.height : 1366
}, {
duration: 2000,
easing: randomEasing,
onFinish: function onFinish() {
if (isLogoIn) {
animateLogo(false);
}
}
});
logoIn = !isLogoIn;
}
animateLogo(logoIn);
};
var logo = game.addChild(new Logo());
logo.x = -logo.width;
logo.y = -logo.height;
tween(logo, {
x: 1024,
y: 1366
}, {
duration: 2000,
easing: tween.elasticIn
});
// Add a text 'Easing' in bottom center
var easingText = new Text2('Easing', {
size: 150,
fill: 0xFFFFFF
});
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 = 2732; // Bottom of the game height
easingText.tint = 0xFFFFFF;
game.addChild(easingText);