Code edit (1 edits merged)
Please save this source code
User prompt
Toca Cinema: The Lost Egg
Initial prompt
Toca cinema (march 2009). The powerpuff girls are inside the cinema. Tap on the play button to make the screen come to life. It will be a movie about “the lost egg”. Egg hatching scene at scene 1 a brown chick scene at scene 2 having a baby bird wash scene at scene 3 eating worms scene at scene 4 giant baby brown bird scene at scene 5 blue mom bird and baby brown bird flying through the clouds scene at scene 6 for end
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var MovieScreen = Container.expand(function () { var self = Container.call(this); var screenBg = self.attachAsset('screen', { anchorX: 0.5, anchorY: 0.5 }); self.currentScene = 0; self.moviePlaying = false; self.chickSize = 1; self.movieElements = []; self.startMovie = function () { self.moviePlaying = true; self.currentScene = 1; self.showScene1(); }; self.showScene1 = function () { self.clearScene(); var egg = self.addChild(LK.getAsset('egg', { anchorX: 0.5, anchorY: 0.5 })); egg.x = 0; egg.y = 0; self.movieElements.push(egg); egg.down = function () { LK.getSound('crack').play(); tween(egg, { scaleX: 1.2, scaleY: 1.2 }, { duration: 300, onFinish: function onFinish() { LK.setTimeout(function () { self.showScene2(); }, 500); } }); }; }; self.showScene2 = function () { self.clearScene(); self.currentScene = 2; var chick = self.addChild(LK.getAsset('chick', { anchorX: 0.5, anchorY: 0.5, scaleX: self.chickSize, scaleY: self.chickSize })); chick.x = 0; chick.y = 0; self.movieElements.push(chick); chick.down = function () { LK.getSound('chirp').play(); tween(chick, { y: chick.y - 30 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { tween(chick, { y: chick.y + 30 }, { duration: 200, easing: tween.easeIn }); } }); }; LK.setTimeout(function () { self.showScene3(); }, 3000); }; self.showScene3 = function () { self.clearScene(); self.currentScene = 3; var chick = self.addChild(LK.getAsset('chick', { anchorX: 0.5, anchorY: 0.5, scaleX: self.chickSize, scaleY: self.chickSize })); chick.x = 0; chick.y = 0; self.movieElements.push(chick); for (var i = 0; i < 5; i++) { var bubble = self.addChild(LK.getAsset('bubble', { anchorX: 0.5, anchorY: 0.5 })); bubble.x = Math.random() * 400 - 200; bubble.y = Math.random() * 300 - 150; self.movieElements.push(bubble); bubble.down = function () { LK.getSound('splash').play(); tween(this, { alpha: 0, scaleX: 1.5, scaleY: 1.5 }, { duration: 300, onFinish: function onFinish() { this.destroy(); } }); }; } LK.setTimeout(function () { self.showScene4(); }, 4000); }; self.showScene4 = function () { self.clearScene(); self.currentScene = 4; var chick = self.addChild(LK.getAsset('chick', { anchorX: 0.5, anchorY: 0.5, scaleX: self.chickSize, scaleY: self.chickSize })); chick.x = 0; chick.y = 0; self.movieElements.push(chick); for (var i = 0; i < 3; i++) { var worm = self.addChild(LK.getAsset('worm', { anchorX: 0.5, anchorY: 0.5 })); worm.x = Math.random() * 300 - 150; worm.y = Math.random() * 200 - 100; self.movieElements.push(worm); worm.down = function () { self.chickSize += 0.3; tween(chick, { scaleX: self.chickSize, scaleY: self.chickSize }, { duration: 500 }); tween(this, { alpha: 0 }, { duration: 300, onFinish: function onFinish() { this.destroy(); } }); }; } LK.setTimeout(function () { self.showScene5(); }, 5000); }; self.showScene5 = function () { self.clearScene(); self.currentScene = 5; var bigChick = self.addChild(LK.getAsset('chick', { anchorX: 0.5, anchorY: 0.5, scaleX: 2.5, scaleY: 2.5 })); bigChick.x = 0; bigChick.y = 0; self.movieElements.push(bigChick); bigChick.down = function () { LK.getSound('chirp').play(); tween(bigChick, { y: bigChick.y - 50 }, { duration: 300, easing: tween.easeOut, onFinish: function onFinish() { tween(bigChick, { y: bigChick.y + 50 }, { duration: 300, easing: tween.easeIn }); } }); }; LK.setTimeout(function () { self.showScene6(); }, 3000); }; self.showScene6 = function () { self.clearScene(); self.currentScene = 6; var chick = self.addChild(LK.getAsset('chick', { anchorX: 0.5, anchorY: 0.5, scaleX: 2, scaleY: 2 })); chick.x = -200; chick.y = 0; self.movieElements.push(chick); var momBird = self.addChild(LK.getAsset('momBird', { anchorX: 0.5, anchorY: 0.5 })); momBird.x = 200; momBird.y = 0; self.movieElements.push(momBird); for (var i = 0; i < 4; i++) { var cloud = self.addChild(LK.getAsset('cloud', { anchorX: 0.5, anchorY: 0.5, alpha: 0.7 })); cloud.x = Math.random() * 600 - 300; cloud.y = Math.random() * 400 - 200; self.movieElements.push(cloud); tween(cloud, { x: cloud.x + 100 }, { duration: 3000 + Math.random() * 2000 }); } momBird.down = function () { tween(chick, { x: 0 }, { duration: 1000 }); tween(momBird, { x: 0 }, { duration: 1000, onFinish: function onFinish() { LK.setTimeout(function () { self.restartMovie(); }, 2000); } }); }; }; self.clearScene = function () { for (var i = 0; i < self.movieElements.length; i++) { self.movieElements[i].destroy(); } self.movieElements = []; }; self.restartMovie = function () { self.moviePlaying = false; self.currentScene = 0; self.chickSize = 1; self.clearScene(); }; return self; }); var PowerpuffGirl = Container.expand(function (color) { var self = Container.call(this); var girl = self.attachAsset(color, { anchorX: 0.5, anchorY: 0.5 }); self.react = function () { tween(girl, { scaleX: 1.1, scaleY: 1.1 }, { duration: 200, onFinish: function onFinish() { tween(girl, { scaleX: 1, scaleY: 1 }, { duration: 200 }); } }); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Create theater background var theater = game.addChild(LK.getAsset('theater', { anchorX: 0.5, anchorY: 0.5 })); theater.x = 1024; theater.y = 1366; // Create movie screen var movieScreen = game.addChild(new MovieScreen()); movieScreen.x = 1024; movieScreen.y = 800; // Create play button var playButton = game.addChild(LK.getAsset('playButton', { anchorX: 0.5, anchorY: 0.5 })); playButton.x = 1024; playButton.y = 800; // Create play button text var playText = new Text2('▶', { size: 100, fill: 0xFFFFFF }); playText.anchor.set(0.5, 0.5); playButton.addChild(playText); // Create seats var seats = []; for (var i = 0; i < 3; i++) { var seat = game.addChild(LK.getAsset('seat', { anchorX: 0.5, anchorY: 0.5 })); seat.x = 500 + i * 350; seat.y = 1800; seats.push(seat); } // Create Powerpuff Girls var blossom = game.addChild(new PowerpuffGirl('blossom')); blossom.x = 500; blossom.y = 1750; var bubbles = game.addChild(new PowerpuffGirl('bubbles')); bubbles.x = 850; bubbles.y = 1750; var buttercup = game.addChild(new PowerpuffGirl('buttercup')); buttercup.x = 1200; buttercup.y = 1750; var girls = [blossom, bubbles, buttercup]; // Play button interaction playButton.down = function () { if (!movieScreen.moviePlaying) { playButton.alpha = 0; movieScreen.startMovie(); // Make girls react for (var i = 0; i < girls.length; i++) { girls[i].react(); } LK.playMusic('theaterMusic'); } }; // Game update loop game.update = function () { // Make girls react occasionally during movie if (movieScreen.moviePlaying && LK.ticks % 180 === 0) { var randomGirl = girls[Math.floor(Math.random() * girls.length)]; randomGirl.react(); } // Show play button when movie is not playing if (!movieScreen.moviePlaying) { playButton.alpha = 1; } }; // Title display var titleText = new Text2('Toca Cinema: The Lost Egg', { size: 60, fill: 0xFFFFFF }); titleText.anchor.set(0.5, 0); LK.gui.top.addChild(titleText); titleText.y = 50;
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var MovieScreen = Container.expand(function () {
var self = Container.call(this);
var screenBg = self.attachAsset('screen', {
anchorX: 0.5,
anchorY: 0.5
});
self.currentScene = 0;
self.moviePlaying = false;
self.chickSize = 1;
self.movieElements = [];
self.startMovie = function () {
self.moviePlaying = true;
self.currentScene = 1;
self.showScene1();
};
self.showScene1 = function () {
self.clearScene();
var egg = self.addChild(LK.getAsset('egg', {
anchorX: 0.5,
anchorY: 0.5
}));
egg.x = 0;
egg.y = 0;
self.movieElements.push(egg);
egg.down = function () {
LK.getSound('crack').play();
tween(egg, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 300,
onFinish: function onFinish() {
LK.setTimeout(function () {
self.showScene2();
}, 500);
}
});
};
};
self.showScene2 = function () {
self.clearScene();
self.currentScene = 2;
var chick = self.addChild(LK.getAsset('chick', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: self.chickSize,
scaleY: self.chickSize
}));
chick.x = 0;
chick.y = 0;
self.movieElements.push(chick);
chick.down = function () {
LK.getSound('chirp').play();
tween(chick, {
y: chick.y - 30
}, {
duration: 200,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(chick, {
y: chick.y + 30
}, {
duration: 200,
easing: tween.easeIn
});
}
});
};
LK.setTimeout(function () {
self.showScene3();
}, 3000);
};
self.showScene3 = function () {
self.clearScene();
self.currentScene = 3;
var chick = self.addChild(LK.getAsset('chick', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: self.chickSize,
scaleY: self.chickSize
}));
chick.x = 0;
chick.y = 0;
self.movieElements.push(chick);
for (var i = 0; i < 5; i++) {
var bubble = self.addChild(LK.getAsset('bubble', {
anchorX: 0.5,
anchorY: 0.5
}));
bubble.x = Math.random() * 400 - 200;
bubble.y = Math.random() * 300 - 150;
self.movieElements.push(bubble);
bubble.down = function () {
LK.getSound('splash').play();
tween(this, {
alpha: 0,
scaleX: 1.5,
scaleY: 1.5
}, {
duration: 300,
onFinish: function onFinish() {
this.destroy();
}
});
};
}
LK.setTimeout(function () {
self.showScene4();
}, 4000);
};
self.showScene4 = function () {
self.clearScene();
self.currentScene = 4;
var chick = self.addChild(LK.getAsset('chick', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: self.chickSize,
scaleY: self.chickSize
}));
chick.x = 0;
chick.y = 0;
self.movieElements.push(chick);
for (var i = 0; i < 3; i++) {
var worm = self.addChild(LK.getAsset('worm', {
anchorX: 0.5,
anchorY: 0.5
}));
worm.x = Math.random() * 300 - 150;
worm.y = Math.random() * 200 - 100;
self.movieElements.push(worm);
worm.down = function () {
self.chickSize += 0.3;
tween(chick, {
scaleX: self.chickSize,
scaleY: self.chickSize
}, {
duration: 500
});
tween(this, {
alpha: 0
}, {
duration: 300,
onFinish: function onFinish() {
this.destroy();
}
});
};
}
LK.setTimeout(function () {
self.showScene5();
}, 5000);
};
self.showScene5 = function () {
self.clearScene();
self.currentScene = 5;
var bigChick = self.addChild(LK.getAsset('chick', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2.5,
scaleY: 2.5
}));
bigChick.x = 0;
bigChick.y = 0;
self.movieElements.push(bigChick);
bigChick.down = function () {
LK.getSound('chirp').play();
tween(bigChick, {
y: bigChick.y - 50
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(bigChick, {
y: bigChick.y + 50
}, {
duration: 300,
easing: tween.easeIn
});
}
});
};
LK.setTimeout(function () {
self.showScene6();
}, 3000);
};
self.showScene6 = function () {
self.clearScene();
self.currentScene = 6;
var chick = self.addChild(LK.getAsset('chick', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 2,
scaleY: 2
}));
chick.x = -200;
chick.y = 0;
self.movieElements.push(chick);
var momBird = self.addChild(LK.getAsset('momBird', {
anchorX: 0.5,
anchorY: 0.5
}));
momBird.x = 200;
momBird.y = 0;
self.movieElements.push(momBird);
for (var i = 0; i < 4; i++) {
var cloud = self.addChild(LK.getAsset('cloud', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.7
}));
cloud.x = Math.random() * 600 - 300;
cloud.y = Math.random() * 400 - 200;
self.movieElements.push(cloud);
tween(cloud, {
x: cloud.x + 100
}, {
duration: 3000 + Math.random() * 2000
});
}
momBird.down = function () {
tween(chick, {
x: 0
}, {
duration: 1000
});
tween(momBird, {
x: 0
}, {
duration: 1000,
onFinish: function onFinish() {
LK.setTimeout(function () {
self.restartMovie();
}, 2000);
}
});
};
};
self.clearScene = function () {
for (var i = 0; i < self.movieElements.length; i++) {
self.movieElements[i].destroy();
}
self.movieElements = [];
};
self.restartMovie = function () {
self.moviePlaying = false;
self.currentScene = 0;
self.chickSize = 1;
self.clearScene();
};
return self;
});
var PowerpuffGirl = Container.expand(function (color) {
var self = Container.call(this);
var girl = self.attachAsset(color, {
anchorX: 0.5,
anchorY: 0.5
});
self.react = function () {
tween(girl, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 200,
onFinish: function onFinish() {
tween(girl, {
scaleX: 1,
scaleY: 1
}, {
duration: 200
});
}
});
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
****/
// Create theater background
var theater = game.addChild(LK.getAsset('theater', {
anchorX: 0.5,
anchorY: 0.5
}));
theater.x = 1024;
theater.y = 1366;
// Create movie screen
var movieScreen = game.addChild(new MovieScreen());
movieScreen.x = 1024;
movieScreen.y = 800;
// Create play button
var playButton = game.addChild(LK.getAsset('playButton', {
anchorX: 0.5,
anchorY: 0.5
}));
playButton.x = 1024;
playButton.y = 800;
// Create play button text
var playText = new Text2('▶', {
size: 100,
fill: 0xFFFFFF
});
playText.anchor.set(0.5, 0.5);
playButton.addChild(playText);
// Create seats
var seats = [];
for (var i = 0; i < 3; i++) {
var seat = game.addChild(LK.getAsset('seat', {
anchorX: 0.5,
anchorY: 0.5
}));
seat.x = 500 + i * 350;
seat.y = 1800;
seats.push(seat);
}
// Create Powerpuff Girls
var blossom = game.addChild(new PowerpuffGirl('blossom'));
blossom.x = 500;
blossom.y = 1750;
var bubbles = game.addChild(new PowerpuffGirl('bubbles'));
bubbles.x = 850;
bubbles.y = 1750;
var buttercup = game.addChild(new PowerpuffGirl('buttercup'));
buttercup.x = 1200;
buttercup.y = 1750;
var girls = [blossom, bubbles, buttercup];
// Play button interaction
playButton.down = function () {
if (!movieScreen.moviePlaying) {
playButton.alpha = 0;
movieScreen.startMovie();
// Make girls react
for (var i = 0; i < girls.length; i++) {
girls[i].react();
}
LK.playMusic('theaterMusic');
}
};
// Game update loop
game.update = function () {
// Make girls react occasionally during movie
if (movieScreen.moviePlaying && LK.ticks % 180 === 0) {
var randomGirl = girls[Math.floor(Math.random() * girls.length)];
randomGirl.react();
}
// Show play button when movie is not playing
if (!movieScreen.moviePlaying) {
playButton.alpha = 1;
}
};
// Title display
var titleText = new Text2('Toca Cinema: The Lost Egg', {
size: 60,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0);
LK.gui.top.addChild(titleText);
titleText.y = 50;