User prompt
significantly increase velocity change amount after touching the screen
User prompt
have the game always look for the touch and continually adjust the velocity after the user touches the screen
User prompt
when the user taps the screen have the velocity increase by 1 unit and have the direction be in the exact opposite direction of the touch
User prompt
when the user taps the screen change the velocity of the hero
User prompt
allow the user to change the velocity of the hero by tapping the screen
User prompt
allow the hero to have a velocity
User prompt
whenever the screen is touched moved the hero in the exact opposite direction
User prompt
Fix Bug: 'Uncaught TypeError: Graphics is not a constructor' in or related to this line: 'var border = new Graphics();' Line Number: 28
User prompt
lets add a border around the visible area of the screen
User prompt
lets have a hero that starts in the center of the screen
Code edit (1 edits merged)
Please save this source code
Initial prompt
Cosmic Container: Alien Ambush
/**** * Classes ****/ var Hero = Container.expand(function () { var self = Container.call(this); var heroGraphics = self.attachAsset('hero', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { self.x += self.vx; self.y += self.vy; }; self.vx = 0; self.vy = 0; self.on('down', function (obj) { var event = obj.event; var pos = event.getLocalPosition(game); self.vx = (pos.x - self.x) / 100; self.vy = (pos.y - self.y) / 100; }); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Create border around the visible area of the screen var border = LK.getAsset('border', { width: 2048, height: 2732, color: 0xFFFFFF, shape: 'box' }); game.addChild(border); var hero = game.addChild(new Hero()); hero.x = 2048 / 2; hero.y = 2732 / 2; LK.on('tick', function () { hero.update(); });
===================================================================
--- original.js
+++ change.js
@@ -6,10 +6,20 @@
var heroGraphics = self.attachAsset('hero', {
anchorX: 0.5,
anchorY: 0.5
});
+ self.update = function () {
+ self.x += self.vx;
+ self.y += self.vy;
+ };
self.vx = 0;
self.vy = 0;
+ self.on('down', function (obj) {
+ var event = obj.event;
+ var pos = event.getLocalPosition(game);
+ self.vx = (pos.x - self.x) / 100;
+ self.vy = (pos.y - self.y) / 100;
+ });
});
/****
* Initialize Game
@@ -30,5 +40,8 @@
});
game.addChild(border);
var hero = game.addChild(new Hero());
hero.x = 2048 / 2;
-hero.y = 2732 / 2;
\ No newline at end of file
+hero.y = 2732 / 2;
+LK.on('tick', function () {
+ hero.update();
+});
\ No newline at end of file
Create the top down view of what it would look to be inside of a very dark space ship's empty cargo bay.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a top down view of an astronaut in a bright yellow space suit. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
create a round bright orange energy orb. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
create a scary space monster. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Create a yellow Play button. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
show a bright green package. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
create an escape hatch with a red exit sign on it. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.