User prompt
move Cosmic Credits a bit lower
User prompt
put Cosmic Credits below High Score
User prompt
make a new currency named "Cosmic Credits" under High Score. 5 cosmic credits per enemy
User prompt
under high score, make a currency system called "Cosmic Credits"
User prompt
name the button test
User prompt
add an interactive button asset at the bottom left of the screen
User prompt
make the font size on the button 50
User prompt
change the button name to "10 Bullets: 50 Cosmic Credits"
User prompt
Fix Bug: 'TypeError: self.containsPoint is not a function' in this line: 'if (self.containsPoint(pos)) {' Line Number: 83
User prompt
Fix Bug: 'TypeError: self.containsPoint is not a function' in this line: 'if (self.containsPoint(pos)) {' Line Number: 83
User prompt
Fix Bug: 'TypeError: self.containsPoint is not a function' in this line: 'if (self.containsPoint(pos)) {' Line Number: 83
User prompt
at the bottom left of the screen, add a button
User prompt
put the button on the bottom left
User prompt
make the button grey so that it is visible
User prompt
make the button visible
User prompt
add button on the bottom left of the screen. Call the button "10 Bullets: 50 Cosmic Credits"
User prompt
remove the lower red line
User prompt
make enemy and bulletpack disappear and become null when hitting the red line
User prompt
move the red line to 5/8 of the screen
User prompt
make the hero a bit lower
User prompt
make the hero a bit loweer
User prompt
make the hero a bit lower
User prompt
make the bottom button a button
User prompt
if i have 50 cosmic credits and i press on the bottom button, i will gain 10 purplebullets
User prompt
the button should be interactive
===================================================================
--- original.js
+++ change.js
@@ -65,24 +65,19 @@
}
self.speed += 0.02 + LK.ticks * 0.0001; // Increase speed over time with an accelerating factor
};
});
-// Button class
-var Button = Container.expand(function (text, onClickCallback) {
+var Button = Container.expand(function (text, positionX, positionY, onClickCallback) {
var self = Container.call(this);
var buttonText = new Text2(text, {
- size: 100,
+ size: 200,
fill: "#ffffff"
});
buttonText.anchor.set(0.5);
self.addChild(buttonText);
- self.y = game.height - buttonText.height / 2 - 50; // Position at the bottom of the screen
- self.x = buttonText.width / 2 + 50; // Position at the bottom left
+ self.x = positionX;
+ self.y = positionY;
self.interactive = true;
- self.containsPoint = function (point) {
- var bounds = buttonText.getBounds();
- return point.x >= bounds.x + self.x - buttonText.width / 2 && point.x <= bounds.x + self.x + buttonText.width / 2 && point.y >= bounds.y + self.y - buttonText.height / 2 && point.y <= bounds.y + self.y + buttonText.height / 2;
- };
self.on('down', function (obj) {
var event = obj.event;
var pos = event.getLocalPosition(game);
if (self.containsPoint(pos)) {
@@ -154,16 +149,8 @@
self.addCredits = function (amount) {
self.amount += amount;
self.creditTxt.setText('Cosmic Credits: ' + self.amount);
};
- self.spendCredits = function (amount) {
- if (self.amount >= amount) {
- self.amount -= amount;
- self.creditTxt.setText('Cosmic Credits: ' + self.amount);
- return true;
- }
- return false;
- };
});
/****
* Initialize Game
@@ -202,9 +189,9 @@
game.addChild(redLine);
// Create character
var hero = game.addChild(new Hero());
hero.x = game.width / 2;
-hero.y = redLine.y + hero.height / 2;
+hero.y = redLine.y + hero.height;
var cosmicCredits = game.addChild(new CosmicCredits());
var highScoreTxt = new Text2('High Score: 0 (WIP)', {
size: 50,
fill: "#ffffff"
@@ -331,13 +318,5 @@
bulletPack.y = -bulletPack.height;
enemies.push(bulletPack); // Add bullet pack to enemies array for collision detection
game.addChild(bulletPack);
}
-});
-// Create Button instance
-var bottomButton = new Button('Bottom Button', function () {
- if (cosmicCredits.spendCredits(50)) {
- hero.bulletLimit += 10;
- bulletCountTxt.setText('Bullets: ' + hero.bulletLimit);
- }
-});
-game.addChild(bottomButton);
\ No newline at end of file
+});
\ No newline at end of file
android. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
letter X png. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
space background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
galaxy background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
galaxy background. High quality
space background.. High contrast