User prompt
refresh the shop price to N.A. after an item is bought
User prompt
if the max for an item has been reached change the price to N.A.
User prompt
add a max of 1 to each items
User prompt
add a maximum amount that an item can be bought, add it for each individual item
User prompt
where has the shop icon gone, add it back
User prompt
Fix Bug: 'Uncaught TypeError: Cannot set properties of undefined (setting 'maxPurchases')' in or related to this line: 'self.maxPurchases = maxPurchases;' Line Number: 70
User prompt
add a maximum amount that an item can be bought, add it for each individual item
User prompt
add a maximum amount that an item can be bought
User prompt
make the flashes milder
User prompt
if the mouse is clicked anywhere else than the shop background or icon put the shop away
User prompt
on the bottom side of the screen display what items are activated
User prompt
add a function for how to earn coins, in this case it should be a button that adds 50 coins
User prompt
subtract the cost of the item with the total coins
User prompt
if the player clicks on an item, check if he can afford that item. if not flash the screen red. if it can afford it then flash the screen green and execute the funtion the belongs to that item
User prompt
display the amount of coins in the top middle
User prompt
add objects for each seperate item and display them in the shop
User prompt
make an object for each seperate item in the code
User prompt
fix the color not changing like stated above
User prompt
when the shop window gets opened check the current coins and change the color of the text accordingly
User prompt
add a score on the top middle that displays the amount of coins you have
User prompt
if the item is unaffordable make the text red, if it is affordable make it white
User prompt
replace the current objects that display the affortability by text boxes that indicate the price and change color if it is affortable
User prompt
Fix Bug: 'Uncaught ReferenceError: ShopItem is not defined' in or related to this line: 'var Item1 = ShopItem.expand(function (price) {' Line Number: 12
User prompt
make each item have their own object
User prompt
make the items display in rows of 3
===================================================================
--- original.js
+++ change.js
@@ -1,30 +1,31 @@
/****
* Classes
****/
-var ShopItem = Container.expand(function (id, price) {
- var self = Container.call(this);
- self.id = id;
- self.price = price;
- self.affordable = true;
- self.updateAffordability = function (playerCoins) {
- self.affordable = playerCoins >= self.price;
- self.assetId = self.affordable ? 'itemAffordable' : 'itemExpensive';
- self.refreshAsset();
- };
- self.refreshAsset = function () {
- if (self.asset) {
- self.removeChild(self.asset);
- }
- if (self.assetId) {
- self.asset = self.attachAsset(self.assetId, {
- anchorX: 0.5,
- anchorY: 0.5
- });
- }
- };
- self.refreshAsset();
+var Item1 = ShopItem.expand(function (price) {
+ var self = ShopItem.call(this, 'item1', price);
});
+var Item2 = ShopItem.expand(function (price) {
+ var self = ShopItem.call(this, 'item2', price);
+});
+var Item3 = ShopItem.expand(function (price) {
+ var self = ShopItem.call(this, 'item3', price);
+});
+var Item4 = ShopItem.expand(function (price) {
+ var self = ShopItem.call(this, 'item4', price);
+});
+var Item5 = ShopItem.expand(function (price) {
+ var self = ShopItem.call(this, 'item5', price);
+});
+var Item6 = ShopItem.expand(function (price) {
+ var self = ShopItem.call(this, 'item6', price);
+});
+var Item7 = ShopItem.expand(function (price) {
+ var self = ShopItem.call(this, 'item7', price);
+});
+var Item8 = ShopItem.expand(function (price) {
+ var self = ShopItem.call(this, 'item8', price);
+});
var ShopMenu = Container.expand(function () {
var self = Container.call(this);
self.visible = false;
self.items = [];
@@ -66,16 +67,16 @@
var shopMenu = game.addChild(new ShopMenu());
shopMenu.x = 1024; // Center of the screen
shopMenu.y = 1366; // Middle of the screen
// Sample items for the shop
-shopMenu.addItem(new ShopItem('item1', 100));
-shopMenu.addItem(new ShopItem('item2', 200));
-shopMenu.addItem(new ShopItem('item3', 300));
-shopMenu.addItem(new ShopItem('item4', 400));
-shopMenu.addItem(new ShopItem('item5', 500));
-shopMenu.addItem(new ShopItem('item6', 600));
-shopMenu.addItem(new ShopItem('item7', 700));
-shopMenu.addItem(new ShopItem('item8', 800));
+shopMenu.addItem(new Item1(100));
+shopMenu.addItem(new Item2(200));
+shopMenu.addItem(new Item3(300));
+shopMenu.addItem(new Item4(400));
+shopMenu.addItem(new Item5(500));
+shopMenu.addItem(new Item6(600));
+shopMenu.addItem(new Item7(700));
+shopMenu.addItem(new Item8(800));
// Position shop items in rows of 3
var itemOffsetX = 200;
var itemOffsetY = 200;
var itemsPerRow = 3;