User prompt
Fix Bug: 'TypeError: LK.stage.getChildByName is not a function' in this line: 'var car = LK.stage.getChildByName('car');' Line Number: 10
User prompt
when the carcolor asset is clicked remove the car asset and spawn the car_2 asset
Code edit (1 edits merged)
Please save this source code
User prompt
Fix Bug: 'TypeError: LK.stageContainer.getChildByName is not a function' in this line: 'var carAsset = LK.stageContainer.getChildByName('car');' Line Number: 11
User prompt
Fix Bug: 'TypeError: LK.stage.getChildByName is not a function' in this line: 'var carAsset = LK.stage.getChildByName('car');' Line Number: 11
User prompt
when change color asset is pressed, change the car asset from car to car_2. if it is pressed again change it back
Code edit (1 edits merged)
Please save this source code
User prompt
move the 'change car color' text 100 pixels left
Code edit (1 edits merged)
Please save this source code
User prompt
move the 'change car color' text 100 pixels left
User prompt
move the 'change car color' text 100 pixels left
User prompt
in the text make two lines. the first one saying: change car. and the second one saying: color
User prompt
move the 'change car color' text 100 pixels left
User prompt
move the 'change car color' text 100 pixels left
User prompt
move the 'change car color' text 100 pixels left
User prompt
move the 'change car color' text 150 pixels up
User prompt
move the text so teh middle of the text is at the middle of the asset
Code edit (1 edits merged)
Please save this source code
User prompt
place a text inside the car color asset, stating: change car color
User prompt
move car color asset 400 pixels up
User prompt
place the settings background in front of the car. in z index
User prompt
add asset settings background
User prompt
when the settings cog is clicked again remove the car color asset again
User prompt
make the car color asset appear if the settings icon is pressed
User prompt
add asset car color
===================================================================
--- original.js
+++ change.js
@@ -4,11 +4,20 @@
self.visible = false;
});
var CarColor = Container.expand(function () {
var self = Container.call(this);
+ self.findCarByName = function (name) {
+ var children = LK.stage.children;
+ for (var i = 0; i < children.length; i++) {
+ if (children[i].name === name) {
+ return children[i];
+ }
+ }
+ return null;
+ };
var carColorGraphics = self.createAsset('carColor', 'Car Color Asset', 0.5, 0.5);
carColorGraphics.on('down', function () {
- var car = LK.stage.getChildByName('car');
+ var car = self.findCarByName('car');
if (car) {
car.destroy();
}
var car2Graphics = self.createAsset('car_2', 'Car 2 Asset', 0.5, 0.5);