User prompt
In the TraderDialogue class, add 2 horizonally aligned BasicButtons underneath the dialogueBackground; the first button has a 'tick' asset and its callback calls the TraderDialogue's callback with a true, while the second button has a "cross" asset and similarly returns false in the callback
Code edit (1 edits merged)
Please save this source code
User prompt
Move the PlantButton class below the BasicButton
User prompt
The BasicButton should return self at the bottom and the PlantButton should inherit from the BasicButton
Code edit (1 edits merged)
Please save this source code
User prompt
Only create the BasicButton's imageAsset if the imageName is defined, including in the updateImage function
User prompt
Add an updateImage function to the basicbutton class which destroys and replaces the imageAsset if it exists
User prompt
Replace the PlantButton's button asset with a BasicButton
Code edit (1 edits merged)
Please save this source code
User prompt
Add a new BasicButton class that inherits from ConfigContainer and takes in 3 params: imageName, callback and config. The button should be comprised of a buttonBackground asset and an asset derived from the imageName, positioned on top of each other. When the buttonBackground asset is clicked, it should fire off the callback
User prompt
Rename the "button" asset to "navigationButton" and update the asset usage in the NavigationButton class
User prompt
Create a new TraderDialogue class which extends the ConfigContainer class and takes in 6 params: sellName, sellAmount, buyName, buyAmount, callback and config. The class should be comprised of a traderDialogue background, with 3 horizon assets, the first has the id of sellName and has a borderText showing the sellAmount before it, the second is an arrow, and the third has the id of buyName and has a borderText showing the buyAmount. If either the sellName or buyName is "credits" then the respective asset and borderText should be replaced with a CurrencyText instead.
User prompt
fruit should have a random x flip
Code edit (5 edits merged)
Please save this source code
User prompt
Add an update function to the PlantButton class that takes in a plantName param and checks whether the plantName param is different from the cached plantName var and creates an asset at the same position as the button with an id of the plantName, destroying the previous plantName asset if it exists
User prompt
The PlantButton should have an update method that takes in a plantName parameter and does the following: cache the plantName in a plantName var, and if the plantName is different from the cached plantName then create an asset with an id of plantName and destroy the previous one if it exists.
User prompt
Create a new PlantButton class which will have a plantButton asset offset at y = PLANT_BUTTON_OFFSET, and an arrow asset offset at y = PLANT_BUTTON_OFFSET/2
User prompt
Add a new global called PLANT_BUTTON_OFFSET = -250, then create a new PlantButton class which will have a plantButton asset offset at y = PLANT_BUTTON_OFFSET, and an arrow asset offset at y = PLANT_BUTTON_OFFSET/2
Code edit (1 edits merged)
Please save this source code
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: t is undefined' in or related to this line: 'var planetGraphics = self.createAsset(details.planet, {' Line Number: 677
Code edit (12 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: t is undefined' in or related to this line: 'var planetGraphics = self.createAsset(details.planet, {' Line Number: 677
Code edit (6 edits merged)
Please save this source code
User prompt
In the ship's update function, it should emit a rocket flame particle downward, while the ship's direction is not 0
===================================================================
--- original.js
+++ change.js
@@ -1081,10 +1081,25 @@
horizonAssets[i].x = currentX + horizonAssets[i].width / 2;
currentX += horizonAssets[i].width;
}
// Add interaction
+ var buttonContainer = self.addChild(new Container());
+ var tickButton = buttonContainer.addChild(new BasicButton('tick', function () {
+ callback(true);
+ }, {
+ x: -50,
+ y: dialogueBackground.height / 2 + 20
+ }));
+ var crossButton = buttonContainer.addChild(new BasicButton('cross', function () {
+ callback(false);
+ }, {
+ x: 50,
+ y: dialogueBackground.height / 2 + 20
+ }));
+ buttonContainer.x = -tickButton.width;
+ buttonContainer.y = dialogueBackground.height / 2 + 20;
dialogueBackground.on('down', function () {
- callback();
+ // This event is kept in case there are other interactions intended with the dialogue background itself.
});
});
var BasicButton = ConfigContainer.expand(function (imageName, callback, config) {
var self = ConfigContainer.call(this, config);
@@ -1100,57 +1115,44 @@
});
}
;
self.updateImage = updateImage;
+ self.imageName = imageName;
+ self.imageAsset = imageAsset;
+ self.buttonBackground = buttonBackground;
;
function updateImage(newImageName) {
- if (imageAsset) {
- imageAsset.destroy();
+ if (newImageName !== self.imageName) {
+ self.imageName = newImageName;
+ if (imageAsset) {
+ imageAsset.destroy();
+ }
+ if (newImageName) {
+ imageAsset = self.attachAsset(newImageName, {
+ x: buttonBackground.x,
+ y: buttonBackground.y,
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ }
}
- if (newImageName) {
- imageAsset = self.attachAsset(newImageName, {
- anchorX: 0.5,
- anchorY: 0.5
- });
- }
}
;
buttonBackground.on('down', callback);
return self;
});
-var PlantButton = ConfigContainer.expand(function (config) {
- var self = ConfigContainer.call(this, config);
- var button = new BasicButton('buttonBackground', function () {}, {
- anchorX: 0.5,
- anchorY: 0.5,
- y: PLANT_BUTTON_OFFSET
- });
- self.addChild(button);
+var PlantButton = BasicButton.expand(function (plantName, callback, config) {
+ var self = BasicButton.call(this, plantName, callback, config);
var arrow = self.attachAsset('arrow', {
anchorX: 0.5,
anchorY: 0.5,
y: PLANT_BUTTON_OFFSET / 2
});
- var cachedPlantName;
- var plantAsset;
;
- self.update = update;
+ self.buttonBackground.y = PLANT_BUTTON_OFFSET;
+ self.imageAsset.y = PLANT_BUTTON_OFFSET;
;
- function update(plantName) {
- if (plantName !== cachedPlantName) {
- if (plantAsset) {
- plantAsset.destroy();
- }
- plantAsset = self.attachAsset(plantName, {
- x: button.x,
- y: button.y,
- anchorX: 0.5,
- anchorY: 0.5
- });
- cachedPlantName = plantName;
- }
- }
- ;
+ return self;
});
/****
* Initialize Game
pixel art of a tiny planet. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a planet. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of an alien currency symbol. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a planet made of gold ore. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
plain black background with stars. 2d repeating Texture.
pixel art of a asteroid. Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a cute alien farmer, side view. Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a rocky explosion.. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art flame particle. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a large white, empty, rectangular, speech bubble. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
pixel art of a red chevron. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Pixel art of yellow grapes. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.