Code edit (8 edits merged)
Please save this source code
User prompt
create an asset to set the background called "happyBkg1"
Code edit (1 edits merged)
Please save this source code
User prompt
update code so that heroship follows the pointer
User prompt
Fix Bug: 'TypeError: LK.tween is not a function' in this line: 'LK.tween(self, {' Line Number: 25
User prompt
make it so the heroship moves towards the pointer. tween the position to make the movement smooth.
Initial prompt
Smiley shots
===================================================================
--- original.js
+++ change.js
@@ -18,13 +18,8 @@
bullet.y = self.y - self.height / 2;
game.addChild(bullet);
return bullet;
};
- self.moveTo = function (targetX, targetY) {
- var distance = Math.sqrt(Math.pow(targetX - self.x, 2) + Math.pow(targetY - self.y, 2));
- var duration = distance / self.speed * 60; // Duration based on speed and 60FPS
- self.customTween(self, targetX, targetY, duration);
- };
});
// Hero bullet class
var HeroBullet = Container.expand(function () {
var self = Container.call(this);
@@ -53,14 +48,9 @@
/****
* Game Code
****/
-// Touch controls for hero ship to move towards touch position
// Initialize important asset arrays
-game.on('down', function (obj) {
- var touchPos = obj.event.getLocalPosition(game);
- heroShip.moveTo(touchPos.x, heroShip.y);
-});
var heroBullets = [];
var enemyShips = [];
// Create hero ship
@@ -119,5 +109,10 @@
// Shoot bullets
if (LK.ticks % 30 == 0) {
heroBullets.push(heroShip.shoot());
}
+});
+// Touch controls to make heroShip follow the pointer
+game.on('move', function (obj) {
+ var touchPos = obj.event.getLocalPosition(game);
+ heroShip.x = touchPos.x;
});
\ No newline at end of file
a cute cool looking emoji face. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a cute looking heart. bright red.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
an evil looking emoji. purple and blue colors.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a shiny blue cute star. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A start button. White on Red.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a grey touchpad. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
a bright yellow shiny cute star. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.