/****
* Classes
****/
var TVScreen = Container.expand(function () {
var self = Container.call(this);
var tvFrame = self.attachAsset('tv_frame', {
anchorX: 0.5,
anchorY: 0.5
});
var tvScreen = self.attachAsset('tv_screen', {
anchorX: 0.5,
anchorY: 0.5
});
self.currentScene = 0;
self.isPlaying = false;
self.sceneElements = [];
self.showPlayButton = function () {
if (self.playButton) {
self.playButton.visible = true;
} else {
self.playButton = self.attachAsset('play_button', {
anchorX: 0.5,
anchorY: 0.5
});
}
};
self.hidePlayButton = function () {
if (self.playButton) {
self.playButton.visible = false;
}
};
self.clearScene = function () {
for (var i = 0; i < self.sceneElements.length; i++) {
self.sceneElements[i].destroy();
}
self.sceneElements = [];
};
self.showScene = function (sceneNumber) {
self.clearScene();
switch (sceneNumber) {
case 1:
self.showScene1();
break;
case 2:
self.showScene2();
break;
case 3:
self.showScene3();
break;
case 4:
self.showScene4();
break;
case 5:
self.showScene5();
break;
case 6:
self.showScene6();
break;
case 7:
self.showScene7();
break;
case 8:
self.showScene8();
break;
}
};
self.showScene1 = function () {
var bing = LK.getAsset('bing_bunny', {
anchorX: 0.5,
anchorY: 0.5,
x: -300,
y: 0
});
var window = LK.getAsset('window', {
anchorX: 0.5,
anchorY: 0.5,
x: 200,
y: -100
});
var airplane = LK.getAsset('airplane', {
anchorX: 0.5,
anchorY: 0.5,
x: 250,
y: -150
});
self.addChild(bing);
self.addChild(window);
self.addChild(airplane);
self.sceneElements.push(bing, window, airplane);
};
self.showScene2 = function () {
var bing = LK.getAsset('bing_bunny', {
anchorX: 0.5,
anchorY: 0.5,
x: -200,
y: 0
});
var sula = LK.getAsset('sula', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0
});
var amma = LK.getAsset('amma', {
anchorX: 0.5,
anchorY: 0.5,
x: 200,
y: 0
});
var earmuffs = LK.getAsset('earmuffs', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -150
});
self.addChild(bing);
self.addChild(sula);
self.addChild(amma);
self.addChild(earmuffs);
self.sceneElements.push(bing, sula, amma, earmuffs);
};
self.showScene3 = function () {
var bing = LK.getAsset('bing_bunny', {
anchorX: 0.5,
anchorY: 0.5,
x: -100,
y: 0
});
var sula = LK.getAsset('sula', {
anchorX: 0.5,
anchorY: 0.5,
x: 100,
y: 0
});
var earmuffs = LK.getAsset('earmuffs', {
anchorX: 0.5,
anchorY: 0.5,
x: -100,
y: -150
});
self.addChild(bing);
self.addChild(sula);
self.addChild(earmuffs);
self.sceneElements.push(bing, sula, earmuffs);
};
self.showScene4 = function () {
var bing = LK.getAsset('bing_bunny', {
anchorX: 0.5,
anchorY: 0.5,
x: -200,
y: 0
});
var window = LK.getAsset('window', {
anchorX: 0.5,
anchorY: 0.5,
x: 200,
y: -100
});
var firework1 = LK.getAsset('firework', {
anchorX: 0.5,
anchorY: 0.5,
x: 150,
y: -200
});
var firework2 = LK.getAsset('firework', {
anchorX: 0.5,
anchorY: 0.5,
x: 250,
y: -150
});
var earmuffs = LK.getAsset('earmuffs', {
anchorX: 0.5,
anchorY: 0.5,
x: -200,
y: -150
});
self.addChild(bing);
self.addChild(window);
self.addChild(firework1);
self.addChild(firework2);
self.addChild(earmuffs);
self.sceneElements.push(bing, window, firework1, firework2, earmuffs);
};
self.showScene5 = function () {
var bing = LK.getAsset('bing_bunny', {
anchorX: 0.5,
anchorY: 0.5,
x: -200,
y: 50
});
var sula = LK.getAsset('sula', {
anchorX: 0.5,
anchorY: 0.5,
x: -50,
y: 50
});
var amma = LK.getAsset('amma', {
anchorX: 0.5,
anchorY: 0.5,
x: 100,
y: 50
});
var firework1 = LK.getAsset('firework', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -200
});
var firework2 = LK.getAsset('firework', {
anchorX: 0.5,
anchorY: 0.5,
x: 200,
y: -150
});
var firework3 = LK.getAsset('firework', {
anchorX: 0.5,
anchorY: 0.5,
x: -150,
y: -180
});
self.addChild(bing);
self.addChild(sula);
self.addChild(amma);
self.addChild(firework1);
self.addChild(firework2);
self.addChild(firework3);
self.sceneElements.push(bing, sula, amma, firework1, firework2, firework3);
};
self.showScene6 = function () {
var bing = LK.getAsset('bing_bunny', {
anchorX: 0.5,
anchorY: 0.5,
x: -100,
y: 0
});
var bigFirework = LK.getAsset('big_firework', {
anchorX: 0.5,
anchorY: 0.5,
x: 100,
y: -150
});
var scaredText = new Text2('AHHHHHHH!', {
size: 80,
fill: 0xFF0000
});
scaredText.anchor.set(0.5, 0.5);
scaredText.x = -100;
scaredText.y = -200;
self.addChild(bing);
self.addChild(bigFirework);
self.addChild(scaredText);
self.sceneElements.push(bing, bigFirework, scaredText);
};
self.showScene7 = function () {
var bing = LK.getAsset('bing_bunny', {
anchorX: 0.5,
anchorY: 0.5,
x: -100,
y: 0
});
var flop = LK.getAsset('flop', {
anchorX: 0.5,
anchorY: 0.5,
x: 100,
y: 0
});
var earGloves = LK.getAsset('ear_gloves', {
anchorX: 0.5,
anchorY: 0.5,
x: -100,
y: -150
});
self.addChild(bing);
self.addChild(flop);
self.addChild(earGloves);
self.sceneElements.push(bing, flop, earGloves);
};
self.showScene8 = function () {
var bing = LK.getAsset('bing_bunny', {
anchorX: 0.5,
anchorY: 0.5,
x: -200,
y: 0
});
var window = LK.getAsset('window', {
anchorX: 0.5,
anchorY: 0.5,
x: 200,
y: -100
});
var rainbow1 = LK.getAsset('rainbow_firework', {
anchorX: 0.5,
anchorY: 0.5,
x: 150,
y: -200
});
var rainbow2 = LK.getAsset('rainbow_firework', {
anchorX: 0.5,
anchorY: 0.5,
x: 250,
y: -150
});
var rainbow3 = LK.getAsset('rainbow_firework', {
anchorX: 0.5,
anchorY: 0.5,
x: 100,
y: -250
});
var earGloves = LK.getAsset('ear_gloves', {
anchorX: 0.5,
anchorY: 0.5,
x: -200,
y: -150
});
self.addChild(bing);
self.addChild(window);
self.addChild(rainbow1);
self.addChild(rainbow2);
self.addChild(rainbow3);
self.addChild(earGloves);
self.sceneElements.push(bing, window, rainbow1, rainbow2, rainbow3, earGloves);
};
self.down = function (x, y, obj) {
if (!self.isPlaying) {
self.isPlaying = true;
self.hidePlayButton();
self.currentScene = 1;
self.showScene(self.currentScene);
} else {
self.nextScene();
}
LK.getSound('click').play();
};
self.nextScene = function () {
if (self.currentScene < 8) {
self.currentScene++;
self.showScene(self.currentScene);
if (self.currentScene == 4 || self.currentScene == 5) {
LK.getSound('firework_sound').play();
} else if (self.currentScene == 6) {
LK.getSound('scared_sound').play();
}
} else {
self.resetStory();
}
};
self.resetStory = function () {
self.isPlaying = false;
self.currentScene = 0;
self.clearScene();
self.showPlayButton();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Sounds
// Story Elements
// Bing Bunny Story Characters
// Powerpuff Girls characters
// TV and Background
// Create room background
var background = game.attachAsset('room_background', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
// Create TV screen in center
var tvScreen = game.addChild(new TVScreen());
tvScreen.x = 1024;
tvScreen.y = 1200;
// Create Powerpuff Girls characters
var blossom = game.attachAsset('blossom', {
anchorX: 0.5,
anchorY: 1,
x: 400,
y: 2200
});
var bubbles = game.attachAsset('bubbles', {
anchorX: 0.5,
anchorY: 1,
x: 1024,
y: 2200
});
var buttercup = game.attachAsset('buttercup', {
anchorX: 0.5,
anchorY: 1,
x: 1648,
y: 2200
});
// Show initial play button
tvScreen.showPlayButton();
// Create title text
var titleText = new Text2('Bing Bunny Fireworks Story TV', {
size: 120,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0);
titleText.x = 1024;
titleText.y = 100;
game.addChild(titleText);
// Create instruction text
var instructionText = new Text2('Tap the TV to watch the story!', {
size: 80,
fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0);
instructionText.x = 1024;
instructionText.y = 2400;
game.addChild(instructionText);
game.update = function () {
// No continuous updates needed for this story-based game
}; /****
* Classes
****/
var TVScreen = Container.expand(function () {
var self = Container.call(this);
var tvFrame = self.attachAsset('tv_frame', {
anchorX: 0.5,
anchorY: 0.5
});
var tvScreen = self.attachAsset('tv_screen', {
anchorX: 0.5,
anchorY: 0.5
});
self.currentScene = 0;
self.isPlaying = false;
self.sceneElements = [];
self.showPlayButton = function () {
if (self.playButton) {
self.playButton.visible = true;
} else {
self.playButton = self.attachAsset('play_button', {
anchorX: 0.5,
anchorY: 0.5
});
}
};
self.hidePlayButton = function () {
if (self.playButton) {
self.playButton.visible = false;
}
};
self.clearScene = function () {
for (var i = 0; i < self.sceneElements.length; i++) {
self.sceneElements[i].destroy();
}
self.sceneElements = [];
};
self.showScene = function (sceneNumber) {
self.clearScene();
switch (sceneNumber) {
case 1:
self.showScene1();
break;
case 2:
self.showScene2();
break;
case 3:
self.showScene3();
break;
case 4:
self.showScene4();
break;
case 5:
self.showScene5();
break;
case 6:
self.showScene6();
break;
case 7:
self.showScene7();
break;
case 8:
self.showScene8();
break;
}
};
self.showScene1 = function () {
var bing = LK.getAsset('bing_bunny', {
anchorX: 0.5,
anchorY: 0.5,
x: -300,
y: 0
});
var window = LK.getAsset('window', {
anchorX: 0.5,
anchorY: 0.5,
x: 200,
y: -100
});
var airplane = LK.getAsset('airplane', {
anchorX: 0.5,
anchorY: 0.5,
x: 250,
y: -150
});
self.addChild(bing);
self.addChild(window);
self.addChild(airplane);
self.sceneElements.push(bing, window, airplane);
};
self.showScene2 = function () {
var bing = LK.getAsset('bing_bunny', {
anchorX: 0.5,
anchorY: 0.5,
x: -200,
y: 0
});
var sula = LK.getAsset('sula', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: 0
});
var amma = LK.getAsset('amma', {
anchorX: 0.5,
anchorY: 0.5,
x: 200,
y: 0
});
var earmuffs = LK.getAsset('earmuffs', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -150
});
self.addChild(bing);
self.addChild(sula);
self.addChild(amma);
self.addChild(earmuffs);
self.sceneElements.push(bing, sula, amma, earmuffs);
};
self.showScene3 = function () {
var bing = LK.getAsset('bing_bunny', {
anchorX: 0.5,
anchorY: 0.5,
x: -100,
y: 0
});
var sula = LK.getAsset('sula', {
anchorX: 0.5,
anchorY: 0.5,
x: 100,
y: 0
});
var earmuffs = LK.getAsset('earmuffs', {
anchorX: 0.5,
anchorY: 0.5,
x: -100,
y: -150
});
self.addChild(bing);
self.addChild(sula);
self.addChild(earmuffs);
self.sceneElements.push(bing, sula, earmuffs);
};
self.showScene4 = function () {
var bing = LK.getAsset('bing_bunny', {
anchorX: 0.5,
anchorY: 0.5,
x: -200,
y: 0
});
var window = LK.getAsset('window', {
anchorX: 0.5,
anchorY: 0.5,
x: 200,
y: -100
});
var firework1 = LK.getAsset('firework', {
anchorX: 0.5,
anchorY: 0.5,
x: 150,
y: -200
});
var firework2 = LK.getAsset('firework', {
anchorX: 0.5,
anchorY: 0.5,
x: 250,
y: -150
});
var earmuffs = LK.getAsset('earmuffs', {
anchorX: 0.5,
anchorY: 0.5,
x: -200,
y: -150
});
self.addChild(bing);
self.addChild(window);
self.addChild(firework1);
self.addChild(firework2);
self.addChild(earmuffs);
self.sceneElements.push(bing, window, firework1, firework2, earmuffs);
};
self.showScene5 = function () {
var bing = LK.getAsset('bing_bunny', {
anchorX: 0.5,
anchorY: 0.5,
x: -200,
y: 50
});
var sula = LK.getAsset('sula', {
anchorX: 0.5,
anchorY: 0.5,
x: -50,
y: 50
});
var amma = LK.getAsset('amma', {
anchorX: 0.5,
anchorY: 0.5,
x: 100,
y: 50
});
var firework1 = LK.getAsset('firework', {
anchorX: 0.5,
anchorY: 0.5,
x: 0,
y: -200
});
var firework2 = LK.getAsset('firework', {
anchorX: 0.5,
anchorY: 0.5,
x: 200,
y: -150
});
var firework3 = LK.getAsset('firework', {
anchorX: 0.5,
anchorY: 0.5,
x: -150,
y: -180
});
self.addChild(bing);
self.addChild(sula);
self.addChild(amma);
self.addChild(firework1);
self.addChild(firework2);
self.addChild(firework3);
self.sceneElements.push(bing, sula, amma, firework1, firework2, firework3);
};
self.showScene6 = function () {
var bing = LK.getAsset('bing_bunny', {
anchorX: 0.5,
anchorY: 0.5,
x: -100,
y: 0
});
var bigFirework = LK.getAsset('big_firework', {
anchorX: 0.5,
anchorY: 0.5,
x: 100,
y: -150
});
var scaredText = new Text2('AHHHHHHH!', {
size: 80,
fill: 0xFF0000
});
scaredText.anchor.set(0.5, 0.5);
scaredText.x = -100;
scaredText.y = -200;
self.addChild(bing);
self.addChild(bigFirework);
self.addChild(scaredText);
self.sceneElements.push(bing, bigFirework, scaredText);
};
self.showScene7 = function () {
var bing = LK.getAsset('bing_bunny', {
anchorX: 0.5,
anchorY: 0.5,
x: -100,
y: 0
});
var flop = LK.getAsset('flop', {
anchorX: 0.5,
anchorY: 0.5,
x: 100,
y: 0
});
var earGloves = LK.getAsset('ear_gloves', {
anchorX: 0.5,
anchorY: 0.5,
x: -100,
y: -150
});
self.addChild(bing);
self.addChild(flop);
self.addChild(earGloves);
self.sceneElements.push(bing, flop, earGloves);
};
self.showScene8 = function () {
var bing = LK.getAsset('bing_bunny', {
anchorX: 0.5,
anchorY: 0.5,
x: -200,
y: 0
});
var window = LK.getAsset('window', {
anchorX: 0.5,
anchorY: 0.5,
x: 200,
y: -100
});
var rainbow1 = LK.getAsset('rainbow_firework', {
anchorX: 0.5,
anchorY: 0.5,
x: 150,
y: -200
});
var rainbow2 = LK.getAsset('rainbow_firework', {
anchorX: 0.5,
anchorY: 0.5,
x: 250,
y: -150
});
var rainbow3 = LK.getAsset('rainbow_firework', {
anchorX: 0.5,
anchorY: 0.5,
x: 100,
y: -250
});
var earGloves = LK.getAsset('ear_gloves', {
anchorX: 0.5,
anchorY: 0.5,
x: -200,
y: -150
});
self.addChild(bing);
self.addChild(window);
self.addChild(rainbow1);
self.addChild(rainbow2);
self.addChild(rainbow3);
self.addChild(earGloves);
self.sceneElements.push(bing, window, rainbow1, rainbow2, rainbow3, earGloves);
};
self.down = function (x, y, obj) {
if (!self.isPlaying) {
self.isPlaying = true;
self.hidePlayButton();
self.currentScene = 1;
self.showScene(self.currentScene);
} else {
self.nextScene();
}
LK.getSound('click').play();
};
self.nextScene = function () {
if (self.currentScene < 8) {
self.currentScene++;
self.showScene(self.currentScene);
if (self.currentScene == 4 || self.currentScene == 5) {
LK.getSound('firework_sound').play();
} else if (self.currentScene == 6) {
LK.getSound('scared_sound').play();
}
} else {
self.resetStory();
}
};
self.resetStory = function () {
self.isPlaying = false;
self.currentScene = 0;
self.clearScene();
self.showPlayButton();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87CEEB
});
/****
* Game Code
****/
// Sounds
// Story Elements
// Bing Bunny Story Characters
// Powerpuff Girls characters
// TV and Background
// Create room background
var background = game.attachAsset('room_background', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
});
// Create TV screen in center
var tvScreen = game.addChild(new TVScreen());
tvScreen.x = 1024;
tvScreen.y = 1200;
// Create Powerpuff Girls characters
var blossom = game.attachAsset('blossom', {
anchorX: 0.5,
anchorY: 1,
x: 400,
y: 2200
});
var bubbles = game.attachAsset('bubbles', {
anchorX: 0.5,
anchorY: 1,
x: 1024,
y: 2200
});
var buttercup = game.attachAsset('buttercup', {
anchorX: 0.5,
anchorY: 1,
x: 1648,
y: 2200
});
// Show initial play button
tvScreen.showPlayButton();
// Create title text
var titleText = new Text2('Bing Bunny Fireworks Story TV', {
size: 120,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0);
titleText.x = 1024;
titleText.y = 100;
game.addChild(titleText);
// Create instruction text
var instructionText = new Text2('Tap the TV to watch the story!', {
size: 80,
fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0);
instructionText.x = 1024;
instructionText.y = 2400;
game.addChild(instructionText);
game.update = function () {
// No continuous updates needed for this story-based game
};