Code edit (1 edits merged)
Please save this source code
User prompt
Blossom's Sound Adventure
Initial prompt
Toca sounds (2007-2008). The powerpuff girls have a sound book called “blossom’s child”. Tap on the text child blossom gasp sound button, or the text blossom snoring sound button, or the text pretend snow sound button, or the text snowstorm sound button, or the child blossom gasp 2 sound button.
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var SoundButton = Container.expand(function (text, soundId, color) { var self = Container.call(this); // Create button background shape var buttonWidth = 480; var buttonHeight = 120; // Create background rectangle using a simple colored shape var background = LK.getAsset('box', { width: buttonWidth, height: buttonHeight, color: color, shape: 'box' }); background.anchor.set(0.5, 0.5); self.addChild(background); // Create text label var label = new Text2(text, { size: 48, fill: 0xFFFFFF, wordWrap: true, wordWrapWidth: buttonWidth - 40 }); label.anchor.set(0.5, 0.5); self.addChild(label); // Store sound reference self.soundId = soundId; self.originalScale = 1; // Button press animation and sound self.down = function (x, y, obj) { // Scale down animation tween(self, { scaleX: 0.9, scaleY: 0.9 }, { duration: 100 }); // Play sound LK.getSound(self.soundId).play(); // Flash effect tween(background, { tint: 0xffffff }, { duration: 150, onFinish: function onFinish() { tween(background, { tint: color }, { duration: 150 }); } }); }; self.up = function (x, y, obj) { // Scale back to normal tween(self, { scaleX: self.originalScale, scaleY: self.originalScale }, { duration: 100 }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xff69b4 }); /**** * Game Code ****/ // Set a vibrant pink background game.setBackgroundColor(0xff1493); // Create title text var titleText = new Text2("Blossom's Sound Adventure", { size: 72, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); titleText.x = 2048 / 2; titleText.y = 100; game.addChild(titleText); // Create subtitle var subtitleText = new Text2("Tap the buttons to hear Blossom sounds!", { size: 36, fill: 0xFFFF99 }); subtitleText.anchor.set(0.5, 0); subtitleText.x = 2048 / 2; subtitleText.y = 200; game.addChild(subtitleText); // Array to store all buttons var soundButtons = []; // Button data with colors and positions var buttonData = [{ text: "Child Blossom Gasp", soundId: "childBlossomGasp", color: 0xff6b9d, x: 2048 / 2, y: 400 }, { text: "Blossom Snoring", soundId: "blossomSnoring", color: 0x9d6bff, x: 2048 / 2, y: 580 }, { text: "Pretend Snow", soundId: "pretendSnow", color: 0x6b9dff, x: 2048 / 2, y: 760 }, { text: "Snowstorm", soundId: "snowstorm", color: 0x6bffff, x: 2048 / 2, y: 940 }, { text: "Child Blossom Gasp 2", soundId: "childBlossomGasp2", color: 0xff9d6b, x: 2048 / 2, y: 1120 }]; // Create sound buttons for (var i = 0; i < buttonData.length; i++) { var data = buttonData[i]; var button = new SoundButton(data.text, data.soundId, data.color); button.x = data.x; button.y = data.y; soundButtons.push(button); game.addChild(button); } // Add decorative elements var decorativeText = new Text2("🌸 Interactive Sound Book 🌸", { size: 48, fill: 0xFFFF99 }); decorativeText.anchor.set(0.5, 0); decorativeText.x = 2048 / 2; decorativeText.y = 1400; game.addChild(decorativeText); // Game update loop (minimal for this type of game) game.update = function () { // No continuous updates needed for a sound book game // All interactions are handled by button events };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var SoundButton = Container.expand(function (text, soundId, color) {
var self = Container.call(this);
// Create button background shape
var buttonWidth = 480;
var buttonHeight = 120;
// Create background rectangle using a simple colored shape
var background = LK.getAsset('box', {
width: buttonWidth,
height: buttonHeight,
color: color,
shape: 'box'
});
background.anchor.set(0.5, 0.5);
self.addChild(background);
// Create text label
var label = new Text2(text, {
size: 48,
fill: 0xFFFFFF,
wordWrap: true,
wordWrapWidth: buttonWidth - 40
});
label.anchor.set(0.5, 0.5);
self.addChild(label);
// Store sound reference
self.soundId = soundId;
self.originalScale = 1;
// Button press animation and sound
self.down = function (x, y, obj) {
// Scale down animation
tween(self, {
scaleX: 0.9,
scaleY: 0.9
}, {
duration: 100
});
// Play sound
LK.getSound(self.soundId).play();
// Flash effect
tween(background, {
tint: 0xffffff
}, {
duration: 150,
onFinish: function onFinish() {
tween(background, {
tint: color
}, {
duration: 150
});
}
});
};
self.up = function (x, y, obj) {
// Scale back to normal
tween(self, {
scaleX: self.originalScale,
scaleY: self.originalScale
}, {
duration: 100
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0xff69b4
});
/****
* Game Code
****/
// Set a vibrant pink background
game.setBackgroundColor(0xff1493);
// Create title text
var titleText = new Text2("Blossom's Sound Adventure", {
size: 72,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0);
titleText.x = 2048 / 2;
titleText.y = 100;
game.addChild(titleText);
// Create subtitle
var subtitleText = new Text2("Tap the buttons to hear Blossom sounds!", {
size: 36,
fill: 0xFFFF99
});
subtitleText.anchor.set(0.5, 0);
subtitleText.x = 2048 / 2;
subtitleText.y = 200;
game.addChild(subtitleText);
// Array to store all buttons
var soundButtons = [];
// Button data with colors and positions
var buttonData = [{
text: "Child Blossom Gasp",
soundId: "childBlossomGasp",
color: 0xff6b9d,
x: 2048 / 2,
y: 400
}, {
text: "Blossom Snoring",
soundId: "blossomSnoring",
color: 0x9d6bff,
x: 2048 / 2,
y: 580
}, {
text: "Pretend Snow",
soundId: "pretendSnow",
color: 0x6b9dff,
x: 2048 / 2,
y: 760
}, {
text: "Snowstorm",
soundId: "snowstorm",
color: 0x6bffff,
x: 2048 / 2,
y: 940
}, {
text: "Child Blossom Gasp 2",
soundId: "childBlossomGasp2",
color: 0xff9d6b,
x: 2048 / 2,
y: 1120
}];
// Create sound buttons
for (var i = 0; i < buttonData.length; i++) {
var data = buttonData[i];
var button = new SoundButton(data.text, data.soundId, data.color);
button.x = data.x;
button.y = data.y;
soundButtons.push(button);
game.addChild(button);
}
// Add decorative elements
var decorativeText = new Text2("🌸 Interactive Sound Book 🌸", {
size: 48,
fill: 0xFFFF99
});
decorativeText.anchor.set(0.5, 0);
decorativeText.x = 2048 / 2;
decorativeText.y = 1400;
game.addChild(decorativeText);
// Game update loop (minimal for this type of game)
game.update = function () {
// No continuous updates needed for a sound book game
// All interactions are handled by button events
};