/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var BlossomCharacter = Container.expand(function () { var self = Container.call(this); // Create body parts var body = self.attachAsset('blossom_body', { anchorX: 0.5, anchorY: 0.8, x: 0, y: 100 }); var head = self.attachAsset('blossom_head', { anchorX: 0.5, anchorY: 0.5, x: 0, y: -80 }); var hair = self.attachAsset('blossom_hair', { anchorX: 0.5, anchorY: 0.7, x: 0, y: -150 }); var bow = self.attachAsset('blossom_bow', { anchorX: 0.5, anchorY: 0.5, x: 0, y: -180 }); var leftEye = self.attachAsset('blossom_eye', { anchorX: 0.5, anchorY: 0.5, x: -30, y: -90 }); var rightEye = self.attachAsset('blossom_eye', { anchorX: 0.5, anchorY: 0.5, x: 30, y: -90 }); var leftArm = self.attachAsset('blossom_arm', { anchorX: 0.8, anchorY: 0.5, x: -100, y: -20, rotation: -0.3 }); var rightArm = self.attachAsset('blossom_arm', { anchorX: 0.2, anchorY: 0.5, x: 100, y: -20, rotation: 0.3 }); self.leftHand = self.attachAsset('blossom_hand', { anchorX: 0.5, anchorY: 0.5, x: -150, y: 20 }); self.rightHand = self.attachAsset('blossom_hand', { anchorX: 0.5, anchorY: 0.5, x: 150, y: 20 }); return self; }); var TextPopup = Container.expand(function (message) { var self = Container.call(this); self.textDisplay = new Text2(message, { size: 80, fill: 0xFF1493 }); self.textDisplay.anchor.set(0.5, 0.5); self.addChild(self.textDisplay); self.show = function () { self.alpha = 1; self.scaleX = 0.1; self.scaleY = 0.1; tween(self, { scaleX: 1.2, scaleY: 1.2 }, { duration: 300, easing: tween.bounceOut, onFinish: function onFinish() { tween(self, { scaleX: 1, scaleY: 1 }, { duration: 200, easing: tween.easeOut }); } }); LK.setTimeout(function () { tween(self, { alpha: 0, scaleY: 0.5 }, { duration: 500, easing: tween.easeIn, onFinish: function onFinish() { self.destroy(); } }); }, 2000); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87CEEB }); /**** * Game Code ****/ var blossom = new BlossomCharacter(); blossom.x = 2048 / 2; blossom.y = 2732 / 2 + 100; game.addChild(blossom); var sayings = ["Sugar, spice, and everything nice!", "Let's save the day!", "I'm the leader of the Powerpuff Girls!", "Science rules!", "Girls, let's go!", "Everything must be perfect!", "I love reading!", "Time to kick some butt!", "We're the Powerpuff Girls!"]; var lastTapTime = 0; var doubleTapThreshold = 500; // milliseconds var currentPopup = null; function showTextPopup(message) { if (currentPopup) { currentPopup.destroy(); } currentPopup = new TextPopup(message); currentPopup.x = 2048 / 2; currentPopup.y = 2732 / 2 - 200; game.addChild(currentPopup); currentPopup.show(); } function playRandomSaying() { var randomIndex = Math.floor(Math.random() * sayings.length); var saying = sayings[randomIndex]; showTextPopup(saying); var soundId = 'speak' + (randomIndex + 1); LK.getSound(soundId).play(); } function playBananaSong() { showTextPopup("🍌 Banana Song! 🍌"); LK.getSound('banana_song').play(); } function handleHandTap() { var currentTime = Date.now(); var timeSinceLastTap = currentTime - lastTapTime; if (timeSinceLastTap < doubleTapThreshold) { // Double tap detected playBananaSong(); } else { // Single tap playRandomSaying(); } lastTapTime = currentTime; } blossom.leftHand.down = function (x, y, obj) { handleHandTap(); // Hand press animation tween(blossom.leftHand, { scaleX: 0.8, scaleY: 0.8 }, { duration: 100, onFinish: function onFinish() { tween(blossom.leftHand, { scaleX: 1, scaleY: 1 }, { duration: 100 }); } }); }; blossom.rightHand.down = function (x, y, obj) { handleHandTap(); // Hand press animation tween(blossom.rightHand, { scaleX: 0.8, scaleY: 0.8 }, { duration: 100, onFinish: function onFinish() { tween(blossom.rightHand, { scaleX: 1, scaleY: 1 }, { duration: 100 }); } }); }; // Idle animation for Blossom var idleTimer = 0; game.update = function () { idleTimer++; // Gentle breathing animation if (idleTimer % 120 === 0) { tween(blossom, { scaleY: 1.02 }, { duration: 1000, easing: tween.easeInOut, onFinish: function onFinish() { tween(blossom, { scaleY: 1 }, { duration: 1000, easing: tween.easeInOut }); } }); } // Occasional eye blink if (idleTimer % 180 === 0 && Math.random() < 0.3) { var leftEye = blossom.children[4]; // Left eye var rightEye = blossom.children[5]; // Right eye tween(leftEye, { scaleY: 0.1 }, { duration: 100, onFinish: function onFinish() { tween(leftEye, { scaleY: 1 }, { duration: 100 }); } }); tween(rightEye, { scaleY: 0.1 }, { duration: 100, onFinish: function onFinish() { tween(rightEye, { scaleY: 1 }, { duration: 100 }); } }); } };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var BlossomCharacter = Container.expand(function () {
var self = Container.call(this);
// Create body parts
var body = self.attachAsset('blossom_body', {
anchorX: 0.5,
anchorY: 0.8,
x: 0,
y: 100
});
var head = self.attachAsset('blossom_head', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -80
});
var hair = self.attachAsset('blossom_hair', {
anchorX: 0.5,
anchorY: 0.7,
x: 0,
y: -150
});
var bow = self.attachAsset('blossom_bow', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -180
});
var leftEye = self.attachAsset('blossom_eye', {
anchorX: 0.5,
anchorY: 0.5,
x: -30,
y: -90
});
var rightEye = self.attachAsset('blossom_eye', {
anchorX: 0.5,
anchorY: 0.5,
x: 30,
y: -90
});
var leftArm = self.attachAsset('blossom_arm', {
anchorX: 0.8,
anchorY: 0.5,
x: -100,
y: -20,
rotation: -0.3
});
var rightArm = self.attachAsset('blossom_arm', {
anchorX: 0.2,
anchorY: 0.5,
x: 100,
y: -20,
rotation: 0.3
});
self.leftHand = self.attachAsset('blossom_hand', {
anchorX: 0.5,
anchorY: 0.5,
x: -150,
y: 20
});
self.rightHand = self.attachAsset('blossom_hand', {
anchorX: 0.5,
anchorY: 0.5,
x: 150,
y: 20
});
return self;
});
var TextPopup = Container.expand(function (message) {
var self = Container.call(this);
self.textDisplay = new Text2(message, {
size: 80,
fill: 0xFF1493
});
self.textDisplay.anchor.set(0.5, 0.5);
self.addChild(self.textDisplay);
self.show = function () {
self.alpha = 1;
self.scaleX = 0.1;
self.scaleY = 0.1;
tween(self, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 300,
easing: tween.bounceOut,
onFinish: function onFinish() {
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 200,
easing: tween.easeOut
});
}
});
LK.setTimeout(function () {
tween(self, {
alpha: 0,
scaleY: 0.5
}, {
duration: 500,
easing: tween.easeIn,
onFinish: function onFinish() {
self.destroy();
}
});
}, 2000);
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
var blossom = new BlossomCharacter();
blossom.x = 2048 / 2;
blossom.y = 2732 / 2 + 100;
game.addChild(blossom);
var sayings = ["Sugar, spice, and everything nice!", "Let's save the day!", "I'm the leader of the Powerpuff Girls!", "Science rules!", "Girls, let's go!", "Everything must be perfect!", "I love reading!", "Time to kick some butt!", "We're the Powerpuff Girls!"];
var lastTapTime = 0;
var doubleTapThreshold = 500; // milliseconds
var currentPopup = null;
function showTextPopup(message) {
if (currentPopup) {
currentPopup.destroy();
}
currentPopup = new TextPopup(message);
currentPopup.x = 2048 / 2;
currentPopup.y = 2732 / 2 - 200;
game.addChild(currentPopup);
currentPopup.show();
}
function playRandomSaying() {
var randomIndex = Math.floor(Math.random() * sayings.length);
var saying = sayings[randomIndex];
showTextPopup(saying);
var soundId = 'speak' + (randomIndex + 1);
LK.getSound(soundId).play();
}
function playBananaSong() {
showTextPopup("🍌 Banana Song! 🍌");
LK.getSound('banana_song').play();
}
function handleHandTap() {
var currentTime = Date.now();
var timeSinceLastTap = currentTime - lastTapTime;
if (timeSinceLastTap < doubleTapThreshold) {
// Double tap detected
playBananaSong();
} else {
// Single tap
playRandomSaying();
}
lastTapTime = currentTime;
}
blossom.leftHand.down = function (x, y, obj) {
handleHandTap();
// Hand press animation
tween(blossom.leftHand, {
scaleX: 0.8,
scaleY: 0.8
}, {
duration: 100,
onFinish: function onFinish() {
tween(blossom.leftHand, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
}
});
};
blossom.rightHand.down = function (x, y, obj) {
handleHandTap();
// Hand press animation
tween(blossom.rightHand, {
scaleX: 0.8,
scaleY: 0.8
}, {
duration: 100,
onFinish: function onFinish() {
tween(blossom.rightHand, {
scaleX: 1,
scaleY: 1
}, {
duration: 100
});
}
});
};
// Idle animation for Blossom
var idleTimer = 0;
game.update = function () {
idleTimer++;
// Gentle breathing animation
if (idleTimer % 120 === 0) {
tween(blossom, {
scaleY: 1.02
}, {
duration: 1000,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(blossom, {
scaleY: 1
}, {
duration: 1000,
easing: tween.easeInOut
});
}
});
}
// Occasional eye blink
if (idleTimer % 180 === 0 && Math.random() < 0.3) {
var leftEye = blossom.children[4]; // Left eye
var rightEye = blossom.children[5]; // Right eye
tween(leftEye, {
scaleY: 0.1
}, {
duration: 100,
onFinish: function onFinish() {
tween(leftEye, {
scaleY: 1
}, {
duration: 100
});
}
});
tween(rightEye, {
scaleY: 0.1
}, {
duration: 100,
onFinish: function onFinish() {
tween(rightEye, {
scaleY: 1
}, {
duration: 100
});
}
});
}
};