/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
/****
* Classes
****/
var PowerpuffGirl = Container.expand(function (girlType) {
var self = Container.call(this);
// Store girl type for reference
self.girlType = girlType;
// Create vine
var vine = self.attachAsset('vine', {
anchorX: 0.5,
anchorY: 0
});
// Create girl character
var girl = self.attachAsset(girlType, {
anchorX: 0.5,
anchorY: 0.5
});
// Position girl at bottom of vine
girl.y = 600;
// Track swinging state
self.isSwinging = false;
self.originalRotation = 0;
// Swing method
self.swing = function () {
if (self.isSwinging) return;
self.isSwinging = true;
// Play appropriate yell sound
var soundName = girlType + 'Yell';
LK.getSound(soundName).play();
// Swing animation - rotate vine and girl together
tween(self, {
rotation: -0.5
}, {
duration: 400,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(self, {
rotation: 0.5
}, {
duration: 800,
easing: tween.easeInOut,
onFinish: function onFinish() {
tween(self, {
rotation: 0
}, {
duration: 400,
easing: tween.easeIn,
onFinish: function onFinish() {
self.isSwinging = false;
}
});
}
});
}
});
};
// Handle tap events
self.down = function (x, y, obj) {
self.swing();
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
// Set a bright sky blue background
game.setBackgroundColor(0x87ceeb);
// Create the three Powerpuff Girls on their vines
var blossom = game.addChild(new PowerpuffGirl('blossom'));
var bubbles = game.addChild(new PowerpuffGirl('bubbles'));
var buttercup = game.addChild(new PowerpuffGirl('buttercup'));
// Position the girls across the screen
blossom.x = 2048 / 4;
blossom.y = 200;
bubbles.x = 2048 / 2;
bubbles.y = 200;
buttercup.x = 2048 / 4 * 3;
buttercup.y = 200;
// Add title text
var titleText = new Text2('Tap the Powerpuff Girls!', {
size: 80,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0);
LK.gui.top.addChild(titleText);
titleText.y = 150;
// Add instruction text
var instructionText = new Text2('Tap any girl to hear her Tarzan yell!', {
size: 50,
fill: 0xFFFFFF
});
instructionText.anchor.set(0.5, 0);
LK.gui.bottom.addChild(instructionText);
instructionText.y = -150;
// Game update loop
game.update = function () {
// No specific update logic needed for this simple interaction game
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,111 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var PowerpuffGirl = Container.expand(function (girlType) {
+ var self = Container.call(this);
+ // Store girl type for reference
+ self.girlType = girlType;
+ // Create vine
+ var vine = self.attachAsset('vine', {
+ anchorX: 0.5,
+ anchorY: 0
+ });
+ // Create girl character
+ var girl = self.attachAsset(girlType, {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Position girl at bottom of vine
+ girl.y = 600;
+ // Track swinging state
+ self.isSwinging = false;
+ self.originalRotation = 0;
+ // Swing method
+ self.swing = function () {
+ if (self.isSwinging) return;
+ self.isSwinging = true;
+ // Play appropriate yell sound
+ var soundName = girlType + 'Yell';
+ LK.getSound(soundName).play();
+ // Swing animation - rotate vine and girl together
+ tween(self, {
+ rotation: -0.5
+ }, {
+ duration: 400,
+ easing: tween.easeOut,
+ onFinish: function onFinish() {
+ tween(self, {
+ rotation: 0.5
+ }, {
+ duration: 800,
+ easing: tween.easeInOut,
+ onFinish: function onFinish() {
+ tween(self, {
+ rotation: 0
+ }, {
+ duration: 400,
+ easing: tween.easeIn,
+ onFinish: function onFinish() {
+ self.isSwinging = false;
+ }
+ });
+ }
+ });
+ }
+ });
+ };
+ // Handle tap events
+ self.down = function (x, y, obj) {
+ self.swing();
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0x87ceeb
+});
+
+/****
+* Game Code
+****/
+// Set a bright sky blue background
+game.setBackgroundColor(0x87ceeb);
+// Create the three Powerpuff Girls on their vines
+var blossom = game.addChild(new PowerpuffGirl('blossom'));
+var bubbles = game.addChild(new PowerpuffGirl('bubbles'));
+var buttercup = game.addChild(new PowerpuffGirl('buttercup'));
+// Position the girls across the screen
+blossom.x = 2048 / 4;
+blossom.y = 200;
+bubbles.x = 2048 / 2;
+bubbles.y = 200;
+buttercup.x = 2048 / 4 * 3;
+buttercup.y = 200;
+// Add title text
+var titleText = new Text2('Tap the Powerpuff Girls!', {
+ size: 80,
+ fill: 0xFFFFFF
+});
+titleText.anchor.set(0.5, 0);
+LK.gui.top.addChild(titleText);
+titleText.y = 150;
+// Add instruction text
+var instructionText = new Text2('Tap any girl to hear her Tarzan yell!', {
+ size: 50,
+ fill: 0xFFFFFF
+});
+instructionText.anchor.set(0.5, 0);
+LK.gui.bottom.addChild(instructionText);
+instructionText.y = -150;
+// Game update loop
+game.update = function () {
+ // No specific update logic needed for this simple interaction game
+};
\ No newline at end of file