Code edit (2 edits merged)
Please save this source code
User prompt
Here is the desired behaviour : Start : logo is out and enters to the center with elasticIn Tap : logo leaves with a rancom ...Out easing the, comes back with a random "...In" easing
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the code, too laggy
User prompt
at the end of tween(logo, { x: -logo.width, y: -logo.height }, { duration: 2000, easing: randomEasing }); call the easing in code
User prompt
refoactor the code to reduce duplication
User prompt
ok, now instead of logo.x = -logo.width; logo.y = -logo.height; use a rancom corner
User prompt
add a text "Easing" in bottom center
Code edit (9 edits merged)
Please save this source code
User prompt
text appears black, change it to white
Code edit (1 edits merged)
Please save this source code
User prompt
fill property has a problem; try something else to make text white
User prompt
add text to game instead of gui
User prompt
add a tint FFF to text
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
/****
* 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)
game.down = function (x, y, obj) {
var easingFunctionsIn = [tween.linear, tween.easeIn, tween.elasticIn, tween.bounceIn];
var easingFunctionsOut = [tween.linear, tween.easeOut, tween.elasticOut, tween.bounceOut];
var randomEasing;
if (!logoIn) {
// If logo is out, animate it in
logo.x = -logo.width;
logo.y = -logo.height;
randomEasing = easingFunctionsIn[Math.floor(Math.random() * easingFunctionsIn.length)];
tween(logo, {
x: 1024,
y: 1366
}, {
duration: 2000,
easing: randomEasing
});
logoIn = true;
} else {
// If logo is in, animate it out
randomEasing = easingFunctionsOut[Math.floor(Math.random() * easingFunctionsOut.length)];
tween(logo, {
x: -logo.width,
y: -logo.height
}, {
duration: 2000,
easing: randomEasing
});
logoIn = false;
}
};
game.update = function () {
if (!logoIn) {
// If logo is out, animate it in
//logo.x = -logo.width;
//logo.y = -logo.height;
var easingFunctionsIn = [tween.linear, tween.easeIn, tween.elasticIn, tween.bounceIn];
randomEasing = easingFunctionsIn[Math.floor(Math.random() * easingFunctionsIn.length)];
tween(logo, {
x: 1024,
y: 1366
}, {
duration: 2000,
easing: randomEasing
});
logoIn = true;
}
};
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
});