Code edit (1 edits merged)
Please save this source code
User prompt
Hair Salon Studio
Initial prompt
Toca hair salon 1 (2011). Tap on the character you want to play as, tap on any tool to get started, tap on the colored spray paint to color your hair, tap on any accessory onto your hair, tap on the camera to take a photo
/**** 
* Plugins
****/ 
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1");
/**** 
* Classes
****/ 
var Character = Container.expand(function (type) {
	var self = Container.call(this);
	var face = self.attachAsset('character' + type, {
		anchorX: 0.5,
		anchorY: 0.5
	});
	var hair = self.attachAsset('hair' + type, {
		anchorX: 0.5,
		anchorY: 0.8
	});
	hair.y = -150;
	self.hair = hair;
	self.originalHairColor = hair.tint;
	self.accessories = [];
	self.changeHairColor = function (color) {
		self.hair.tint = color;
	};
	self.addAccessory = function (accessoryType, x, y) {
		var accessory = LK.getAsset(accessoryType, {
			anchorX: 0.5,
			anchorY: 0.5
		});
		accessory.x = x;
		accessory.y = y;
		self.addChild(accessory);
		self.accessories.push(accessory);
	};
	self.clearAccessories = function () {
		for (var i = 0; i < self.accessories.length; i++) {
			self.accessories[i].destroy();
		}
		self.accessories = [];
	};
	self.reset = function () {
		self.hair.tint = self.originalHairColor;
		self.clearAccessories();
	};
	return self;
});
var ColorSwatch = Container.expand(function (color) {
	var self = Container.call(this);
	var swatch = self.attachAsset('colorwheel', {
		anchorX: 0.5,
		anchorY: 0.5,
		scaleX: 0.6,
		scaleY: 0.6
	});
	swatch.tint = color;
	self.color = color;
	self.down = function (x, y, obj) {
		LK.getSound('click').play();
		if (currentCharacter) {
			currentCharacter.changeHairColor(self.color);
			LK.getSound('spray').play();
		}
	};
	return self;
});
var Tool = Container.expand(function (type) {
	var self = Container.call(this);
	var graphic = self.attachAsset(type, {
		anchorX: 0.5,
		anchorY: 0.5
	});
	self.type = type;
	self.isSelected = false;
	self.select = function () {
		self.isSelected = true;
		graphic.tint = 0xFFFF00;
		tween(self, {
			scaleX: 1.2,
			scaleY: 1.2
		}, {
			duration: 200
		});
	};
	self.deselect = function () {
		self.isSelected = false;
		graphic.tint = 0xFFFFFF;
		tween(self, {
			scaleX: 1,
			scaleY: 1
		}, {
			duration: 200
		});
	};
	self.down = function (x, y, obj) {
		LK.getSound('click').play();
		selectTool(self.type);
	};
	return self;
});
var UIButton = Container.expand(function (text, action) {
	var self = Container.call(this);
	var button = self.attachAsset('button', {
		anchorX: 0.5,
		anchorY: 0.5
	});
	var label = new Text2(text, {
		size: 40,
		fill: 0x000000
	});
	label.anchor.set(0.5, 0.5);
	self.addChild(label);
	self.action = action;
	self.down = function (x, y, obj) {
		LK.getSound('click').play();
		tween(self, {
			scaleX: 0.9,
			scaleY: 0.9
		}, {
			duration: 100,
			onFinish: function onFinish() {
				tween(self, {
					scaleX: 1,
					scaleY: 1
				}, {
					duration: 100
				});
			}
		});
		self.action();
	};
	return self;
});
/**** 
* Initialize Game
****/ 
var game = new LK.Game({
	backgroundColor: 0xFFF8DC
});
/**** 
* Game Code
****/ 
// Sound assets
// UI assets
// Accessory assets
// Tool assets
// Hair assets
// Character assets
var currentCharacter = null;
var selectedTool = null;
var tools = [];
var colorSwatches = [];
var characters = [];
var gameState = 'characterSelect'; // 'characterSelect', 'styling'
// Character selection
var characterSelectTitle = new Text2('Choose Your Character', {
	size: 80,
	fill: 0x8B4513
});
characterSelectTitle.anchor.set(0.5, 0.5);
characterSelectTitle.x = 2048 / 2;
characterSelectTitle.y = 200;
game.addChild(characterSelectTitle);
// Create character selection buttons
for (var i = 1; i <= 3; i++) {
	var charPreview = new Character(i);
	charPreview.x = 400 + (i - 1) * 500;
	charPreview.y = 600;
	charPreview.scaleX = 0.6;
	charPreview.scaleY = 0.6;
	charPreview.characterType = i;
	charPreview.down = function (x, y, obj) {
		LK.getSound('click').play();
		startStyling(obj.characterType);
	};
	game.addChild(charPreview);
	characters.push(charPreview);
}
// Tools panel (hidden initially)
var toolsPanel = new Container();
toolsPanel.x = 100;
toolsPanel.y = 400;
toolsPanel.visible = false;
game.addChild(toolsPanel);
var toolTypes = ['scissors', 'brush', 'hairdryer', 'curlingiron', 'spraypaint'];
for (var i = 0; i < toolTypes.length; i++) {
	var tool = new Tool(toolTypes[i]);
	tool.x = 0;
	tool.y = i * 150;
	toolsPanel.addChild(tool);
	tools.push(tool);
}
// Color panel (hidden initially)
var colorPanel = new Container();
colorPanel.x = 1800;
colorPanel.y = 400;
colorPanel.visible = false;
game.addChild(colorPanel);
var colors = [0xFF0000, 0x00FF00, 0x0000FF, 0xFFFF00, 0xFF00FF, 0x00FFFF, 0xFFA500, 0x800080, 0xFFC0CB];
for (var i = 0; i < colors.length; i++) {
	var colorSwatch = new ColorSwatch(colors[i]);
	colorSwatch.x = i % 3 * 100;
	colorSwatch.y = Math.floor(i / 3) * 100;
	colorPanel.addChild(colorSwatch);
	colorSwatches.push(colorSwatch);
}
// Accessories panel (hidden initially)
var accessoriesPanel = new Container();
accessoriesPanel.x = 1800;
accessoriesPanel.y = 800;
accessoriesPanel.visible = false;
game.addChild(accessoriesPanel);
var accessoryTypes = ['bow', 'headband', 'clip'];
for (var i = 0; i < accessoryTypes.length; i++) {
	var accessoryButton = LK.getAsset(accessoryTypes[i], {
		anchorX: 0.5,
		anchorY: 0.5
	});
	accessoryButton.x = i % 2 * 120;
	accessoryButton.y = Math.floor(i / 2) * 80;
	accessoryButton.accessoryType = accessoryTypes[i];
	accessoryButton.down = function (x, y, obj) {
		LK.getSound('click').play();
		selectedTool = 'accessory';
		selectedAccessory = obj.accessoryType;
	};
	accessoriesPanel.addChild(accessoryButton);
}
// Control buttons
var resetButton = new UIButton('Reset', function () {
	if (currentCharacter) {
		currentCharacter.reset();
	}
});
resetButton.x = 1024;
resetButton.y = 2500;
resetButton.visible = false;
game.addChild(resetButton);
var backButton = new UIButton('Back', function () {
	gameState = 'characterSelect';
	showCharacterSelect();
});
backButton.x = 300;
backButton.y = 2500;
backButton.visible = false;
game.addChild(backButton);
// Title for styling mode
var stylingTitle = new Text2('Hair Salon Studio', {
	size: 60,
	fill: 0x8B4513
});
stylingTitle.anchor.set(0.5, 0.5);
stylingTitle.x = 2048 / 2;
stylingTitle.y = 100;
stylingTitle.visible = false;
game.addChild(stylingTitle);
var selectedAccessory = null;
function startStyling(characterType) {
	gameState = 'styling';
	// Hide character selection
	characterSelectTitle.visible = false;
	for (var i = 0; i < characters.length; i++) {
		characters[i].visible = false;
	}
	// Show styling interface
	currentCharacter = new Character(characterType);
	currentCharacter.x = 1024;
	currentCharacter.y = 800;
	game.addChild(currentCharacter);
	toolsPanel.visible = true;
	colorPanel.visible = true;
	accessoriesPanel.visible = true;
	resetButton.visible = true;
	backButton.visible = true;
	stylingTitle.visible = true;
}
function showCharacterSelect() {
	// Hide styling interface
	if (currentCharacter) {
		currentCharacter.destroy();
		currentCharacter = null;
	}
	toolsPanel.visible = false;
	colorPanel.visible = false;
	accessoriesPanel.visible = false;
	resetButton.visible = false;
	backButton.visible = false;
	stylingTitle.visible = false;
	// Show character selection
	characterSelectTitle.visible = true;
	for (var i = 0; i < characters.length; i++) {
		characters[i].visible = true;
	}
	// Reset tool selection
	selectedTool = null;
	for (var i = 0; i < tools.length; i++) {
		tools[i].deselect();
	}
}
function selectTool(toolType) {
	selectedTool = toolType;
	for (var i = 0; i < tools.length; i++) {
		if (tools[i].type === toolType) {
			tools[i].select();
		} else {
			tools[i].deselect();
		}
	}
}
game.down = function (x, y, obj) {
	if (gameState === 'styling' && currentCharacter && selectedTool === 'accessory' && selectedAccessory) {
		var localPos = currentCharacter.toLocal(obj.position);
		currentCharacter.addAccessory(selectedAccessory, localPos.x, localPos.y);
		LK.getSound('click').play();
	}
	if (gameState === 'styling' && currentCharacter && selectedTool === 'scissors') {
		LK.getSound('cut').play();
		LK.effects.flashObject(currentCharacter.hair, 0xFFFFFF, 300);
	}
};
game.update = function () {
	// Game loop updates if needed
}; ===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,326 @@
-/****
+/**** 
+* Plugins
+****/ 
+var tween = LK.import("@upit/tween.v1");
+var storage = LK.import("@upit/storage.v1");
+
+/**** 
+* Classes
+****/ 
+var Character = Container.expand(function (type) {
+	var self = Container.call(this);
+	var face = self.attachAsset('character' + type, {
+		anchorX: 0.5,
+		anchorY: 0.5
+	});
+	var hair = self.attachAsset('hair' + type, {
+		anchorX: 0.5,
+		anchorY: 0.8
+	});
+	hair.y = -150;
+	self.hair = hair;
+	self.originalHairColor = hair.tint;
+	self.accessories = [];
+	self.changeHairColor = function (color) {
+		self.hair.tint = color;
+	};
+	self.addAccessory = function (accessoryType, x, y) {
+		var accessory = LK.getAsset(accessoryType, {
+			anchorX: 0.5,
+			anchorY: 0.5
+		});
+		accessory.x = x;
+		accessory.y = y;
+		self.addChild(accessory);
+		self.accessories.push(accessory);
+	};
+	self.clearAccessories = function () {
+		for (var i = 0; i < self.accessories.length; i++) {
+			self.accessories[i].destroy();
+		}
+		self.accessories = [];
+	};
+	self.reset = function () {
+		self.hair.tint = self.originalHairColor;
+		self.clearAccessories();
+	};
+	return self;
+});
+var ColorSwatch = Container.expand(function (color) {
+	var self = Container.call(this);
+	var swatch = self.attachAsset('colorwheel', {
+		anchorX: 0.5,
+		anchorY: 0.5,
+		scaleX: 0.6,
+		scaleY: 0.6
+	});
+	swatch.tint = color;
+	self.color = color;
+	self.down = function (x, y, obj) {
+		LK.getSound('click').play();
+		if (currentCharacter) {
+			currentCharacter.changeHairColor(self.color);
+			LK.getSound('spray').play();
+		}
+	};
+	return self;
+});
+var Tool = Container.expand(function (type) {
+	var self = Container.call(this);
+	var graphic = self.attachAsset(type, {
+		anchorX: 0.5,
+		anchorY: 0.5
+	});
+	self.type = type;
+	self.isSelected = false;
+	self.select = function () {
+		self.isSelected = true;
+		graphic.tint = 0xFFFF00;
+		tween(self, {
+			scaleX: 1.2,
+			scaleY: 1.2
+		}, {
+			duration: 200
+		});
+	};
+	self.deselect = function () {
+		self.isSelected = false;
+		graphic.tint = 0xFFFFFF;
+		tween(self, {
+			scaleX: 1,
+			scaleY: 1
+		}, {
+			duration: 200
+		});
+	};
+	self.down = function (x, y, obj) {
+		LK.getSound('click').play();
+		selectTool(self.type);
+	};
+	return self;
+});
+var UIButton = Container.expand(function (text, action) {
+	var self = Container.call(this);
+	var button = self.attachAsset('button', {
+		anchorX: 0.5,
+		anchorY: 0.5
+	});
+	var label = new Text2(text, {
+		size: 40,
+		fill: 0x000000
+	});
+	label.anchor.set(0.5, 0.5);
+	self.addChild(label);
+	self.action = action;
+	self.down = function (x, y, obj) {
+		LK.getSound('click').play();
+		tween(self, {
+			scaleX: 0.9,
+			scaleY: 0.9
+		}, {
+			duration: 100,
+			onFinish: function onFinish() {
+				tween(self, {
+					scaleX: 1,
+					scaleY: 1
+				}, {
+					duration: 100
+				});
+			}
+		});
+		self.action();
+	};
+	return self;
+});
+
+/**** 
 * Initialize Game
-****/
+****/ 
 var game = new LK.Game({
-	backgroundColor: 0x000000
-});
\ No newline at end of file
+	backgroundColor: 0xFFF8DC
+});
+
+/**** 
+* Game Code
+****/ 
+// Sound assets
+// UI assets
+// Accessory assets
+// Tool assets
+// Hair assets
+// Character assets
+var currentCharacter = null;
+var selectedTool = null;
+var tools = [];
+var colorSwatches = [];
+var characters = [];
+var gameState = 'characterSelect'; // 'characterSelect', 'styling'
+// Character selection
+var characterSelectTitle = new Text2('Choose Your Character', {
+	size: 80,
+	fill: 0x8B4513
+});
+characterSelectTitle.anchor.set(0.5, 0.5);
+characterSelectTitle.x = 2048 / 2;
+characterSelectTitle.y = 200;
+game.addChild(characterSelectTitle);
+// Create character selection buttons
+for (var i = 1; i <= 3; i++) {
+	var charPreview = new Character(i);
+	charPreview.x = 400 + (i - 1) * 500;
+	charPreview.y = 600;
+	charPreview.scaleX = 0.6;
+	charPreview.scaleY = 0.6;
+	charPreview.characterType = i;
+	charPreview.down = function (x, y, obj) {
+		LK.getSound('click').play();
+		startStyling(obj.characterType);
+	};
+	game.addChild(charPreview);
+	characters.push(charPreview);
+}
+// Tools panel (hidden initially)
+var toolsPanel = new Container();
+toolsPanel.x = 100;
+toolsPanel.y = 400;
+toolsPanel.visible = false;
+game.addChild(toolsPanel);
+var toolTypes = ['scissors', 'brush', 'hairdryer', 'curlingiron', 'spraypaint'];
+for (var i = 0; i < toolTypes.length; i++) {
+	var tool = new Tool(toolTypes[i]);
+	tool.x = 0;
+	tool.y = i * 150;
+	toolsPanel.addChild(tool);
+	tools.push(tool);
+}
+// Color panel (hidden initially)
+var colorPanel = new Container();
+colorPanel.x = 1800;
+colorPanel.y = 400;
+colorPanel.visible = false;
+game.addChild(colorPanel);
+var colors = [0xFF0000, 0x00FF00, 0x0000FF, 0xFFFF00, 0xFF00FF, 0x00FFFF, 0xFFA500, 0x800080, 0xFFC0CB];
+for (var i = 0; i < colors.length; i++) {
+	var colorSwatch = new ColorSwatch(colors[i]);
+	colorSwatch.x = i % 3 * 100;
+	colorSwatch.y = Math.floor(i / 3) * 100;
+	colorPanel.addChild(colorSwatch);
+	colorSwatches.push(colorSwatch);
+}
+// Accessories panel (hidden initially)
+var accessoriesPanel = new Container();
+accessoriesPanel.x = 1800;
+accessoriesPanel.y = 800;
+accessoriesPanel.visible = false;
+game.addChild(accessoriesPanel);
+var accessoryTypes = ['bow', 'headband', 'clip'];
+for (var i = 0; i < accessoryTypes.length; i++) {
+	var accessoryButton = LK.getAsset(accessoryTypes[i], {
+		anchorX: 0.5,
+		anchorY: 0.5
+	});
+	accessoryButton.x = i % 2 * 120;
+	accessoryButton.y = Math.floor(i / 2) * 80;
+	accessoryButton.accessoryType = accessoryTypes[i];
+	accessoryButton.down = function (x, y, obj) {
+		LK.getSound('click').play();
+		selectedTool = 'accessory';
+		selectedAccessory = obj.accessoryType;
+	};
+	accessoriesPanel.addChild(accessoryButton);
+}
+// Control buttons
+var resetButton = new UIButton('Reset', function () {
+	if (currentCharacter) {
+		currentCharacter.reset();
+	}
+});
+resetButton.x = 1024;
+resetButton.y = 2500;
+resetButton.visible = false;
+game.addChild(resetButton);
+var backButton = new UIButton('Back', function () {
+	gameState = 'characterSelect';
+	showCharacterSelect();
+});
+backButton.x = 300;
+backButton.y = 2500;
+backButton.visible = false;
+game.addChild(backButton);
+// Title for styling mode
+var stylingTitle = new Text2('Hair Salon Studio', {
+	size: 60,
+	fill: 0x8B4513
+});
+stylingTitle.anchor.set(0.5, 0.5);
+stylingTitle.x = 2048 / 2;
+stylingTitle.y = 100;
+stylingTitle.visible = false;
+game.addChild(stylingTitle);
+var selectedAccessory = null;
+function startStyling(characterType) {
+	gameState = 'styling';
+	// Hide character selection
+	characterSelectTitle.visible = false;
+	for (var i = 0; i < characters.length; i++) {
+		characters[i].visible = false;
+	}
+	// Show styling interface
+	currentCharacter = new Character(characterType);
+	currentCharacter.x = 1024;
+	currentCharacter.y = 800;
+	game.addChild(currentCharacter);
+	toolsPanel.visible = true;
+	colorPanel.visible = true;
+	accessoriesPanel.visible = true;
+	resetButton.visible = true;
+	backButton.visible = true;
+	stylingTitle.visible = true;
+}
+function showCharacterSelect() {
+	// Hide styling interface
+	if (currentCharacter) {
+		currentCharacter.destroy();
+		currentCharacter = null;
+	}
+	toolsPanel.visible = false;
+	colorPanel.visible = false;
+	accessoriesPanel.visible = false;
+	resetButton.visible = false;
+	backButton.visible = false;
+	stylingTitle.visible = false;
+	// Show character selection
+	characterSelectTitle.visible = true;
+	for (var i = 0; i < characters.length; i++) {
+		characters[i].visible = true;
+	}
+	// Reset tool selection
+	selectedTool = null;
+	for (var i = 0; i < tools.length; i++) {
+		tools[i].deselect();
+	}
+}
+function selectTool(toolType) {
+	selectedTool = toolType;
+	for (var i = 0; i < tools.length; i++) {
+		if (tools[i].type === toolType) {
+			tools[i].select();
+		} else {
+			tools[i].deselect();
+		}
+	}
+}
+game.down = function (x, y, obj) {
+	if (gameState === 'styling' && currentCharacter && selectedTool === 'accessory' && selectedAccessory) {
+		var localPos = currentCharacter.toLocal(obj.position);
+		currentCharacter.addAccessory(selectedAccessory, localPos.x, localPos.y);
+		LK.getSound('click').play();
+	}
+	if (gameState === 'styling' && currentCharacter && selectedTool === 'scissors') {
+		LK.getSound('cut').play();
+		LK.effects.flashObject(currentCharacter.hair, 0xFFFFFF, 300);
+	}
+};
+game.update = function () {
+	// Game loop updates if needed
+};
\ No newline at end of file