User prompt
Make the bounce direction based on the ball intersection angle
User prompt
Don't use intersects, rather calculate if the boot and ball intersects using circle to circle intersections
User prompt
Is game is started, use circle to circle intersection and collision code to allow the boot to kick up the ball.
User prompt
rename finger to boot
User prompt
Remove the intersects code from down handler
User prompt
In tick, don't call ball.move unless game is started
User prompt
When the game starts, the player has to click the game to initially kick the ball. However from this point forward, you kick the ball by hitting it with the finger.
User prompt
When the game starts, the player has to click the game to initially kick the ball. However from this point forward, you kick the ball by hitting it with the finger.
User prompt
Always show finger where the mouse is, don't hide finger when I click the screen
User prompt
Finger should always be visible
User prompt
Show where my finger is with an asset
User prompt
Progress development of game
Initial prompt
Kickup
var Finger = Container.expand(function () { var self = Container.call(this); var fingerGraphics = self.createAsset('finger', 'Finger', .5, .5); }); var Ball = Container.expand(function () { var self = Container.call(this); var ballGraphics = self.createAsset('ball', 'Soccer Ball', .5, .5); self.velocityY = 0; self.gravity = 0.5; self.bounceFactor = 0.7; self.move = function () { self.y += self.velocityY; self.velocityY += self.gravity; if (self.y > 2732 - self.height / 2) { self.velocityY *= -self.bounceFactor; self.y = 2732 - self.height / 2; } }; self.bounce = function () { self.velocityY = -20; }; }); var Game = Container.expand(function () { var self = Container.call(this); stage.on('move', function (obj) { var pos = obj.event.getLocalPosition(self); finger.x = pos.x; finger.y = pos.y; }); var ball = self.addChild(new Ball()); ball.x = 2048 / 2; ball.y = 2732 / 2; var finger = self.addChild(new Finger()); finger.visible = true; var scoreTxt = new Text2('0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(.5, 0); LK.gui.topCenter.addChild(scoreTxt); var isGameOver = false; var isGameStarted = false; stage.on('down', function (obj) { var pos = obj.event.getLocalPosition(self); finger.x = pos.x; finger.y = pos.y; finger.visible = true; if (!isGameStarted) { ball.bounce(); isGameStarted = true; } else if (ball.intersects(finger)) { ball.bounce(); scoreTxt.setText(parseInt(scoreTxt.text) + 1); } }); LK.on('tick', function () { ball.move(); if (ball.y > 2732 - ball.height / 2) { isGameOver = true; } if (isGameOver) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } }); });
===================================================================
--- original.js
+++ change.js
@@ -21,22 +21,16 @@
};
});
var Game = Container.expand(function () {
var self = Container.call(this);
- stage.on('down', function (obj) {
+ stage.on('move', function (obj) {
var pos = obj.event.getLocalPosition(self);
finger.x = pos.x;
finger.y = pos.y;
- finger.visible = true;
- if (ball.intersects(finger)) {
- ball.bounce();
- scoreTxt.setText(parseInt(scoreTxt.text) + 1);
- }
});
var ball = self.addChild(new Ball());
ball.x = 2048 / 2;
ball.y = 2732 / 2;
- ball.velocityY = -20;
var finger = self.addChild(new Finger());
finger.visible = true;
var scoreTxt = new Text2('0', {
size: 150,
@@ -44,15 +38,19 @@
});
scoreTxt.anchor.set(.5, 0);
LK.gui.topCenter.addChild(scoreTxt);
var isGameOver = false;
+ var isGameStarted = false;
stage.on('down', function (obj) {
var pos = obj.event.getLocalPosition(self);
finger.x = pos.x;
finger.y = pos.y;
finger.visible = true;
- if (ball.intersects(finger)) {
+ if (!isGameStarted) {
ball.bounce();
+ isGameStarted = true;
+ } else if (ball.intersects(finger)) {
+ ball.bounce();
scoreTxt.setText(parseInt(scoreTxt.text) + 1);
}
});
LK.on('tick', function () {
Soccer ball. Single Cartoon Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Round soccer boot, cartoon style Single Cartoon Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Cartoon football stadium Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.