User prompt
Face Camera call button of picking two we pick 4 and we show our face and also add John and Bob βͺπ‘ Consider importing and using the following plugins: @upit/facekit.v1
User prompt
Can you make the text bigger
User prompt
You can add another player to it the max limit is 10
User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'toGlobal')' in or related to this line: 'var localPos = self.toLocal(obj.parent.toGlobal(obj.position));' Line Number: 145
User prompt
Code the button of join chat you have to press a random name to chat with or you can pick two of them and you chat with two
User prompt
Fix it
User prompt
Just code It in
User prompt
Add some music
Code edit (1 edits merged)
Please save this source code
User prompt
Wii Menu Simulator
Initial prompt
Wii menu
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var facekit = LK.import("@upit/facekit.v1");
/****
* Classes
****/
var ChatUser = Container.expand(function (userName) {
var self = Container.call(this);
var button = self.attachAsset('userButton', {
anchorX: 0.5,
anchorY: 0.5
});
self.userName = userName;
self.isSelected = false;
var nameText = new Text2(userName, {
size: 45,
fill: 0xFFFFFF
});
nameText.anchor.set(0.5, 0.5);
self.addChild(nameText);
self.select = function () {
if (self.isSelected) return;
self.isSelected = true;
button.tint = 0x4CAF50;
tween(self, {
scaleX: 1.1,
scaleY: 1.1
}, {
duration: 200,
easing: tween.easeOut
});
};
self.deselect = function () {
if (!self.isSelected) return;
self.isSelected = false;
button.tint = 0x1976D2;
tween(self, {
scaleX: 1.0,
scaleY: 1.0
}, {
duration: 200,
easing: tween.easeOut
});
};
self.down = function (x, y, obj) {
if (chatMode === 'userSelection') {
if (self.isSelected) {
self.deselect();
var index = selectedChatUsers.indexOf(self);
if (index > -1) {
selectedChatUsers.splice(index, 1);
}
} else {
if (selectedChatUsers.length < 3) {
self.select();
selectedChatUsers.push(self);
}
}
updateStartChatButton();
}
};
return self;
});
var ChatWindow = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('chatWindow', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.95
});
var messageArea = self.attachAsset('messageBox', {
anchorX: 0.5,
anchorY: 0.5,
y: -100
});
self.messages = [];
self.messageTexts = [];
var closeButton = self.attachAsset('sendButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 700,
y: -500
});
var closeText = new Text2('Close', {
size: 40,
fill: 0xFFFFFF
});
closeText.anchor.set(0.5, 0.5);
closeText.x = 700;
closeText.y = -500;
self.addChild(closeText);
var chatTitleText = new Text2('Chat Room', {
size: 60,
fill: 0xFFFFFF
});
chatTitleText.anchor.set(0.5, 0.5);
chatTitleText.y = -550;
self.addChild(chatTitleText);
self.addMessage = function (userName, message) {
var messageText = userName + ": " + message;
self.messages.push(messageText);
var textObj = new Text2(messageText, {
size: 40,
fill: 0xFFFFFF
});
textObj.anchor.set(0, 0.5);
textObj.x = -750;
textObj.y = -400 + self.messageTexts.length * 40;
self.addChild(textObj);
self.messageTexts.push(textObj);
// Keep only last 15 messages
if (self.messageTexts.length > 15) {
var oldText = self.messageTexts.shift();
self.removeChild(oldText);
// Move remaining messages up
for (var i = 0; i < self.messageTexts.length; i++) {
self.messageTexts[i].y = -400 + i * 40;
}
}
};
self.down = function (x, y, obj) {
// Use the x, y coordinates directly instead of trying to convert obj position
var localPos = self.toLocal({
x: x,
y: y
});
// Check if close button was clicked
if (localPos.x > 600 && localPos.x < 800 && localPos.y > -530 && localPos.y < -470) {
closeChatWindow();
}
};
return self;
});
var MiiCharacter = Container.expand(function () {
var self = Container.call(this);
var body = self.attachAsset('miiCharacter', {
anchorX: 0.5,
anchorY: 0.5
});
self.speedX = (Math.random() - 0.5) * 2;
self.speedY = (Math.random() - 0.5) * 2;
self.floatOffset = Math.random() * Math.PI * 2;
self.floatSpeed = 0.02 + Math.random() * 0.02;
self.update = function () {
self.x += self.speedX;
self.y += self.speedY;
// Floating animation
self.floatOffset += self.floatSpeed;
body.y = Math.sin(self.floatOffset) * 10;
// Bounce off edges
if (self.x < 50 || self.x > 1998) {
self.speedX *= -1;
}
if (self.y < 50 || self.y > 2682) {
self.speedY *= -1;
}
// Keep within bounds
self.x = Math.max(50, Math.min(1998, self.x));
self.y = Math.max(50, Math.min(2682, self.y));
};
return self;
});
var VideoCallWindow = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('videoWindow', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.95
});
// Main user camera view (larger)
var mainFrame = self.attachAsset('faceFrame', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 1.5,
scaleY: 1.5,
x: 0,
y: -200
});
// Participant frames (smaller)
var participantFrames = [];
for (var i = 0; i < 4; i++) {
var frame = self.attachAsset('faceFrame', {
anchorX: 0.5,
anchorY: 0.5,
scaleX: 0.8,
scaleY: 0.8,
x: -600 + i * 400,
y: 300
});
participantFrames.push(frame);
}
// Face tracking indicators
var faceIndicators = [];
for (var i = 0; i < 5; i++) {
var indicator = new Text2('π€', {
size: 30,
fill: 0x4CAF50
});
indicator.anchor.set(0.5, 0.5);
faceIndicators.push(indicator);
self.addChild(indicator);
}
// Participant names
var participantNames = ["You", "John", "Bob", "Alex", "Jordan"];
var nameTexts = [];
for (var i = 0; i < 5; i++) {
var nameText = new Text2(participantNames[i], {
size: 35,
fill: 0xFFFFFF
});
nameText.anchor.set(0.5, 0.5);
nameTexts.push(nameText);
self.addChild(nameText);
}
// Position name texts
nameTexts[0].x = 0;
nameTexts[0].y = -50;
for (var i = 1; i < 5; i++) {
nameTexts[i].x = -600 + (i - 1) * 400;
nameTexts[i].y = 450;
}
// Close button
var closeButton = self.attachAsset('sendButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 800,
y: -600
});
var closeText = new Text2('End Call', {
size: 40,
fill: 0xFFFFFF
});
closeText.anchor.set(0.5, 0.5);
closeText.x = 800;
closeText.y = -600;
self.addChild(closeText);
var titleText = new Text2('Face Camera Call', {
size: 60,
fill: 0xFFFFFF
});
titleText.anchor.set(0.5, 0.5);
titleText.y = -650;
self.addChild(titleText);
self.update = function () {
// Update face tracking for main user
if (facekit.mouthCenter) {
faceIndicators[0].x = facekit.mouthCenter.x * 0.5;
faceIndicators[0].y = -200 + facekit.mouthCenter.y * 0.5;
faceIndicators[0].visible = true;
} else {
faceIndicators[0].visible = false;
}
// Simulate face tracking for other participants
for (var i = 1; i < 5; i++) {
faceIndicators[i].x = -600 + (i - 1) * 400 + Math.sin(Date.now() * 0.001 + i) * 20;
faceIndicators[i].y = 300 + Math.cos(Date.now() * 0.002 + i) * 15;
}
// Voice level indicator for main user
if (facekit.volume > 0.1) {
var scale = 1 + facekit.volume * 0.3;
faceIndicators[0].scaleX = scale;
faceIndicators[0].scaleY = scale;
} else {
faceIndicators[0].scaleX = 1;
faceIndicators[0].scaleY = 1;
}
};
self.down = function (x, y, obj) {
var localPos = self.toLocal({
x: x,
y: y
});
// Check if close button was clicked
if (localPos.x > 700 && localPos.x < 900 && localPos.y > -630 && localPos.y < -570) {
closeVideoCall();
}
};
return self;
});
var WiiChannel = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('channelBackground', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.9
});
var icon = self.attachAsset('channelIcon', {
anchorX: 0.5,
anchorY: 0.5
});
self.channelName = "";
self.isSelected = false;
self.originalScale = 1;
self.setChannel = function (name, color) {
self.channelName = name;
icon.tint = color;
};
self.select = function () {
if (self.isSelected) return;
self.isSelected = true;
tween(self, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 200,
easing: tween.easeOut
});
LK.getSound('menuSelect').play();
};
self.deselect = function () {
if (!self.isSelected) return;
self.isSelected = false;
tween(self, {
scaleX: self.originalScale,
scaleY: self.originalScale
}, {
duration: 200,
easing: tween.easeOut
});
};
self.activate = function () {
tween(self, {
scaleX: 1.5,
scaleY: 1.5,
alpha: 0.8
}, {
duration: 300,
easing: tween.easeOut,
onFinish: function onFinish() {
tween(self, {
scaleX: self.originalScale,
scaleY: self.originalScale,
alpha: 1
}, {
duration: 300,
easing: tween.easeIn
});
}
});
};
return self;
});
var WiiCursor = Container.expand(function () {
var self = Container.call(this);
var cursorGraphic = self.attachAsset('cursor', {
anchorX: 0.5,
anchorY: 0.5
});
self.targetX = 1024;
self.targetY = 1366;
self.update = function () {
// Smooth cursor movement
var dx = self.targetX - self.x;
var dy = self.targetY - self.y;
self.x += dx * 0.15;
self.y += dy * 0.15;
// Subtle pulsing animation
var pulse = 1 + Math.sin(Date.now() * 0.005) * 0.1;
cursorGraphic.scaleX = pulse;
cursorGraphic.scaleY = pulse;
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x87ceeb
});
/****
* Game Code
****/
// Game state variables
var channels = [];
var miis = [];
var selectedChannel = null;
var channelGrid = {
rows: 3,
cols: 4,
offsetX: 0,
offsetY: 0
};
// Chat system variables
var chatMode = 'menu'; // 'menu', 'userSelection', 'chatting', 'videoCall'
var chatUsers = [];
var selectedChatUsers = [];
var currentChatWindow = null;
var currentVideoCall = null;
var joinChatButton = null;
var startChatButton = null;
var randomChatButton = null;
var faceCallButton = null;
// Sample user names for chat
var userNames = ["Alex", "Jordan", "Casey", "Riley", "Morgan", "Taylor", "Avery", "Quinn", "Sage", "River", "Blake", "Cameron", "Drew", "Finley", "Hayden"];
// Sample chat messages
var chatMessages = ["Hey everyone!", "How's it going?", "Anyone playing any good games?", "Love the Wii menu!", "This brings back memories", "Who wants to play Wii Sports?", "Check out this new channel!", "The weather forecast looks good", "Anyone seen the news today?", "Mii characters are so cute!"];
// Create background
var background = game.addChild(LK.getAsset('menuBackground', {
anchorX: 0,
anchorY: 0,
x: 0,
y: 0
}));
// Create Mii characters in background
for (var i = 0; i < 8; i++) {
var mii = new MiiCharacter();
mii.x = Math.random() * 2048;
mii.y = Math.random() * 2732;
miis.push(mii);
game.addChild(mii);
}
// Create channel grid
var channelNames = ["Disc Channel", "Mii Channel", "Photo Channel", "Wii Shop Channel", "Forecast Channel", "News Channel", "Internet Channel", "Nintendo Channel", "Check Mii Out", "TV Guide", "Wii Speak", "Settings"];
var channelColors = [0x4a90e2, 0x7ed321, 0xf5a623, 0xd0021b, 0x50e3c2, 0xb8e986, 0x9013fe, 0xf8e71c, 0xbd10e0, 0x4a4a4a, 0x417505, 0x8b572a];
// Position channels in grid
var startX = 300;
var startY = 400;
var spacingX = 450;
var spacingY = 400;
for (var i = 0; i < channelNames.length; i++) {
var channel = new WiiChannel();
var row = Math.floor(i / channelGrid.cols);
var col = i % channelGrid.cols;
channel.x = startX + col * spacingX;
channel.y = startY + row * spacingY;
channel.setChannel(channelNames[i], channelColors[i]);
channels.push(channel);
game.addChild(channel);
}
// Create cursor
var cursor = new WiiCursor();
game.addChild(cursor);
// Date/time display
var dateTimeText = new Text2(new Date().toLocaleString(), {
size: 60,
fill: 0xFFFFFF
});
dateTimeText.anchor.set(1, 0);
LK.gui.topRight.addChild(dateTimeText);
// Create Join Chat button
joinChatButton = game.addChild(LK.getAsset('chatButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 150
}));
var joinChatText = new Text2('Join Chat', {
size: 50,
fill: 0xFFFFFF
});
joinChatText.anchor.set(0.5, 0.5);
joinChatText.x = 1024;
joinChatText.y = 150;
game.addChild(joinChatText);
// Create Face Camera Call button
faceCallButton = game.addChild(LK.getAsset('faceCallButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1024,
y: 250
}));
var faceCallText = new Text2('Face Camera Call', {
size: 45,
fill: 0xFFFFFF
});
faceCallText.anchor.set(0.5, 0.5);
faceCallText.x = 1024;
faceCallText.y = 250;
game.addChild(faceCallText);
// Initialize chat users
function createChatUsers() {
for (var i = 0; i < userNames.length; i++) {
var chatUser = new ChatUser(userNames[i]);
chatUser.x = 300 + i % 3 * 450;
chatUser.y = 400 + Math.floor(i / 3) * 100;
chatUser.visible = false;
chatUsers.push(chatUser);
game.addChild(chatUser);
}
}
function showUserSelection() {
chatMode = 'userSelection';
// Hide channels and show users
for (var i = 0; i < channels.length; i++) {
channels[i].visible = false;
}
for (var i = 0; i < chatUsers.length; i++) {
chatUsers[i].visible = true;
}
// Create start chat button
startChatButton = game.addChild(LK.getAsset('chatButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 800,
y: 2500,
alpha: 0.5
}));
var startText = new Text2('Start Chat', {
size: 45,
fill: 0xFFFFFF
});
startText.anchor.set(0.5, 0.5);
startText.x = 800;
startText.y = 2500;
game.addChild(startText);
// Create random chat button
randomChatButton = game.addChild(LK.getAsset('chatButton', {
anchorX: 0.5,
anchorY: 0.5,
x: 1300,
y: 2500
}));
var randomText = new Text2('Random Chat', {
size: 45,
fill: 0xFFFFFF
});
randomText.anchor.set(0.5, 0.5);
randomText.x = 1300;
randomText.y = 2500;
game.addChild(randomText);
}
function updateStartChatButton() {
if (startChatButton) {
if (selectedChatUsers.length > 0) {
startChatButton.alpha = 1.0;
} else {
startChatButton.alpha = 0.5;
}
}
}
function startChatWithSelected() {
if (selectedChatUsers.length === 0) return;
chatMode = 'chatting';
// Hide user selection
for (var i = 0; i < chatUsers.length; i++) {
chatUsers[i].visible = false;
}
if (startChatButton) {
startChatButton.visible = false;
}
if (randomChatButton) {
randomChatButton.visible = false;
}
// Create chat window
currentChatWindow = new ChatWindow();
currentChatWindow.x = 1024;
currentChatWindow.y = 1366;
game.addChild(currentChatWindow);
// Add initial messages
var chatParticipants = selectedChatUsers.slice();
LK.setTimeout(function () {
for (var i = 0; i < chatParticipants.length; i++) {
var randomMessage = chatMessages[Math.floor(Math.random() * chatMessages.length)];
currentChatWindow.addMessage(chatParticipants[i].userName, randomMessage);
}
}, 1000);
// Continue adding random messages
var messageInterval = LK.setInterval(function () {
if (chatMode === 'chatting' && chatParticipants.length > 0) {
var randomUser = chatParticipants[Math.floor(Math.random() * chatParticipants.length)];
var randomMessage = chatMessages[Math.floor(Math.random() * chatMessages.length)];
currentChatWindow.addMessage(randomUser.userName, randomMessage);
}
}, 3000);
}
function startRandomChat() {
// Select 1-3 random users
selectedChatUsers = [];
var numUsers = 1 + Math.floor(Math.random() * 3); // 1, 2, or 3 users
for (var i = 0; i < numUsers; i++) {
var randomIndex = Math.floor(Math.random() * chatUsers.length);
var randomUser = chatUsers[randomIndex];
if (selectedChatUsers.indexOf(randomUser) === -1) {
selectedChatUsers.push(randomUser);
randomUser.select();
}
}
LK.setTimeout(function () {
startChatWithSelected();
}, 500);
}
function startVideoCall() {
chatMode = 'videoCall';
// Hide all other elements
for (var i = 0; i < channels.length; i++) {
channels[i].visible = false;
}
joinChatButton.visible = false;
faceCallButton.visible = false;
// Create video call window
currentVideoCall = new VideoCallWindow();
currentVideoCall.x = 1024;
currentVideoCall.y = 1366;
game.addChild(currentVideoCall);
}
function closeVideoCall() {
chatMode = 'menu';
// Clean up video call
if (currentVideoCall) {
game.removeChild(currentVideoCall);
currentVideoCall = null;
}
// Show main menu elements again
for (var i = 0; i < channels.length; i++) {
channels[i].visible = true;
}
joinChatButton.visible = true;
faceCallButton.visible = true;
}
function closeChatWindow() {
chatMode = 'menu';
// Clean up chat
if (currentChatWindow) {
game.removeChild(currentChatWindow);
currentChatWindow = null;
}
// Reset selections
for (var i = 0; i < selectedChatUsers.length; i++) {
selectedChatUsers[i].deselect();
}
selectedChatUsers = [];
// Show channels again
for (var i = 0; i < channels.length; i++) {
channels[i].visible = true;
}
// Hide chat users
for (var i = 0; i < chatUsers.length; i++) {
chatUsers[i].visible = false;
}
if (startChatButton) {
startChatButton.visible = false;
}
if (randomChatButton) {
randomChatButton.visible = false;
}
}
createChatUsers();
// Start playing background music
LK.playMusic('wiiMenuMusic');
// Touch and interaction handling
var isDragging = false;
var lastTouchX = 0;
var lastTouchY = 0;
game.down = function (x, y, obj) {
isDragging = true;
lastTouchX = x;
lastTouchY = y;
cursor.targetX = x;
cursor.targetY = y;
// Check if touching join chat button
if (chatMode === 'menu') {
var dx = x - 1024;
var dy = y - 150;
if (Math.abs(dx) < 150 && Math.abs(dy) < 40) {
showUserSelection();
LK.getSound('menuSelect').play();
return;
}
// Check if touching face camera call button
var fdx = x - 1024;
var fdy = y - 250;
if (Math.abs(fdx) < 175 && Math.abs(fdy) < 40) {
startVideoCall();
LK.getSound('menuSelect').play();
return;
}
}
// Check if touching start chat button
if (chatMode === 'userSelection' && startChatButton && selectedChatUsers.length > 0) {
var dx = x - 800;
var dy = y - 2500;
if (Math.abs(dx) < 150 && Math.abs(dy) < 40) {
startChatWithSelected();
LK.getSound('menuSelect').play();
return;
}
}
// Check if touching random chat button
if (chatMode === 'userSelection' && randomChatButton) {
var dx = x - 1300;
var dy = y - 2500;
if (Math.abs(dx) < 150 && Math.abs(dy) < 40) {
startRandomChat();
LK.getSound('menuSelect').play();
return;
}
}
// Check if touching a channel (only in menu mode)
if (chatMode === 'menu') {
for (var i = 0; i < channels.length; i++) {
var channel = channels[i];
var dx = x - channel.x;
var dy = y - channel.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 200) {
if (selectedChannel && selectedChannel !== channel) {
selectedChannel.deselect();
}
selectedChannel = channel;
channel.select();
break;
}
}
}
};
game.move = function (x, y, obj) {
cursor.targetX = x;
cursor.targetY = y;
if (isDragging) {
var deltaX = x - lastTouchX;
var deltaY = y - lastTouchY;
// Move all channels for scrolling effect
for (var i = 0; i < channels.length; i++) {
channels[i].x += deltaX * 0.5;
channels[i].y += deltaY * 0.5;
}
lastTouchX = x;
lastTouchY = y;
if (Math.abs(deltaX) > 5 || Math.abs(deltaY) > 5) {
LK.getSound('menuMove').play();
}
}
};
game.up = function (x, y, obj) {
isDragging = false;
if (selectedChannel) {
// Check if still over the selected channel
var dx = x - selectedChannel.x;
var dy = y - selectedChannel.y;
var distance = Math.sqrt(dx * dx + dy * dy);
if (distance < 200) {
selectedChannel.activate();
LK.getSound('menuSelect').play();
}
}
};
// Game update loop
var timeUpdateCounter = 0;
game.update = function () {
// Update Mii characters
for (var i = 0; i < miis.length; i++) {
// Miis update automatically through their update method
}
// Update cursor
// Cursor updates automatically through its update method
// Update date/time display every 60 frames (1 second)
timeUpdateCounter++;
if (timeUpdateCounter >= 60) {
dateTimeText.setText(new Date().toLocaleString());
timeUpdateCounter = 0;
}
// Keep channels within reasonable bounds
var centerX = 1024;
var centerY = 1366;
var maxOffsetX = 500;
var maxOffsetY = 300;
if (channels.length > 0) {
var avgX = 0;
var avgY = 0;
for (var i = 0; i < channels.length; i++) {
avgX += channels[i].x;
avgY += channels[i].y;
}
avgX /= channels.length;
avgY /= channels.length;
// Gently pull channels back toward center if they drift too far
if (Math.abs(avgX - centerX) > maxOffsetX || Math.abs(avgY - centerY) > maxOffsetY) {
var pullX = (centerX - avgX) * 0.01;
var pullY = (centerY - avgY) * 0.01;
for (var i = 0; i < channels.length; i++) {
channels[i].x += pullX;
channels[i].y += pullY;
}
}
}
}; ===================================================================
--- original.js
+++ change.js
@@ -1,8 +1,9 @@
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
+var facekit = LK.import("@upit/facekit.v1");
/****
* Classes
****/
@@ -161,8 +162,125 @@
self.y = Math.max(50, Math.min(2682, self.y));
};
return self;
});
+var VideoCallWindow = Container.expand(function () {
+ var self = Container.call(this);
+ var background = self.attachAsset('videoWindow', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ alpha: 0.95
+ });
+ // Main user camera view (larger)
+ var mainFrame = self.attachAsset('faceFrame', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 1.5,
+ scaleY: 1.5,
+ x: 0,
+ y: -200
+ });
+ // Participant frames (smaller)
+ var participantFrames = [];
+ for (var i = 0; i < 4; i++) {
+ var frame = self.attachAsset('faceFrame', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ scaleX: 0.8,
+ scaleY: 0.8,
+ x: -600 + i * 400,
+ y: 300
+ });
+ participantFrames.push(frame);
+ }
+ // Face tracking indicators
+ var faceIndicators = [];
+ for (var i = 0; i < 5; i++) {
+ var indicator = new Text2('π€', {
+ size: 30,
+ fill: 0x4CAF50
+ });
+ indicator.anchor.set(0.5, 0.5);
+ faceIndicators.push(indicator);
+ self.addChild(indicator);
+ }
+ // Participant names
+ var participantNames = ["You", "John", "Bob", "Alex", "Jordan"];
+ var nameTexts = [];
+ for (var i = 0; i < 5; i++) {
+ var nameText = new Text2(participantNames[i], {
+ size: 35,
+ fill: 0xFFFFFF
+ });
+ nameText.anchor.set(0.5, 0.5);
+ nameTexts.push(nameText);
+ self.addChild(nameText);
+ }
+ // Position name texts
+ nameTexts[0].x = 0;
+ nameTexts[0].y = -50;
+ for (var i = 1; i < 5; i++) {
+ nameTexts[i].x = -600 + (i - 1) * 400;
+ nameTexts[i].y = 450;
+ }
+ // Close button
+ var closeButton = self.attachAsset('sendButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 800,
+ y: -600
+ });
+ var closeText = new Text2('End Call', {
+ size: 40,
+ fill: 0xFFFFFF
+ });
+ closeText.anchor.set(0.5, 0.5);
+ closeText.x = 800;
+ closeText.y = -600;
+ self.addChild(closeText);
+ var titleText = new Text2('Face Camera Call', {
+ size: 60,
+ fill: 0xFFFFFF
+ });
+ titleText.anchor.set(0.5, 0.5);
+ titleText.y = -650;
+ self.addChild(titleText);
+ self.update = function () {
+ // Update face tracking for main user
+ if (facekit.mouthCenter) {
+ faceIndicators[0].x = facekit.mouthCenter.x * 0.5;
+ faceIndicators[0].y = -200 + facekit.mouthCenter.y * 0.5;
+ faceIndicators[0].visible = true;
+ } else {
+ faceIndicators[0].visible = false;
+ }
+ // Simulate face tracking for other participants
+ for (var i = 1; i < 5; i++) {
+ faceIndicators[i].x = -600 + (i - 1) * 400 + Math.sin(Date.now() * 0.001 + i) * 20;
+ faceIndicators[i].y = 300 + Math.cos(Date.now() * 0.002 + i) * 15;
+ }
+ // Voice level indicator for main user
+ if (facekit.volume > 0.1) {
+ var scale = 1 + facekit.volume * 0.3;
+ faceIndicators[0].scaleX = scale;
+ faceIndicators[0].scaleY = scale;
+ } else {
+ faceIndicators[0].scaleX = 1;
+ faceIndicators[0].scaleY = 1;
+ }
+ };
+ self.down = function (x, y, obj) {
+ var localPos = self.toLocal({
+ x: x,
+ y: y
+ });
+ // Check if close button was clicked
+ if (localPos.x > 700 && localPos.x < 900 && localPos.y > -630 && localPos.y < -570) {
+ closeVideoCall();
+ }
+ };
+ return self;
+});
var WiiChannel = Container.expand(function () {
var self = Container.call(this);
var background = self.attachAsset('channelBackground', {
anchorX: 0.5,
@@ -267,15 +385,17 @@
offsetX: 0,
offsetY: 0
};
// Chat system variables
-var chatMode = 'menu'; // 'menu', 'userSelection', 'chatting'
+var chatMode = 'menu'; // 'menu', 'userSelection', 'chatting', 'videoCall'
var chatUsers = [];
var selectedChatUsers = [];
var currentChatWindow = null;
+var currentVideoCall = null;
var joinChatButton = null;
var startChatButton = null;
var randomChatButton = null;
+var faceCallButton = null;
// Sample user names for chat
var userNames = ["Alex", "Jordan", "Casey", "Riley", "Morgan", "Taylor", "Avery", "Quinn", "Sage", "River", "Blake", "Cameron", "Drew", "Finley", "Hayden"];
// Sample chat messages
var chatMessages = ["Hey everyone!", "How's it going?", "Anyone playing any good games?", "Love the Wii menu!", "This brings back memories", "Who wants to play Wii Sports?", "Check out this new channel!", "The weather forecast looks good", "Anyone seen the news today?", "Mii characters are so cute!"];
@@ -336,8 +456,23 @@
joinChatText.anchor.set(0.5, 0.5);
joinChatText.x = 1024;
joinChatText.y = 150;
game.addChild(joinChatText);
+// Create Face Camera Call button
+faceCallButton = game.addChild(LK.getAsset('faceCallButton', {
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: 1024,
+ y: 250
+}));
+var faceCallText = new Text2('Face Camera Call', {
+ size: 45,
+ fill: 0xFFFFFF
+});
+faceCallText.anchor.set(0.5, 0.5);
+faceCallText.x = 1024;
+faceCallText.y = 250;
+game.addChild(faceCallText);
// Initialize chat users
function createChatUsers() {
for (var i = 0; i < userNames.length; i++) {
var chatUser = new ChatUser(userNames[i]);
@@ -448,8 +583,36 @@
LK.setTimeout(function () {
startChatWithSelected();
}, 500);
}
+function startVideoCall() {
+ chatMode = 'videoCall';
+ // Hide all other elements
+ for (var i = 0; i < channels.length; i++) {
+ channels[i].visible = false;
+ }
+ joinChatButton.visible = false;
+ faceCallButton.visible = false;
+ // Create video call window
+ currentVideoCall = new VideoCallWindow();
+ currentVideoCall.x = 1024;
+ currentVideoCall.y = 1366;
+ game.addChild(currentVideoCall);
+}
+function closeVideoCall() {
+ chatMode = 'menu';
+ // Clean up video call
+ if (currentVideoCall) {
+ game.removeChild(currentVideoCall);
+ currentVideoCall = null;
+ }
+ // Show main menu elements again
+ for (var i = 0; i < channels.length; i++) {
+ channels[i].visible = true;
+ }
+ joinChatButton.visible = true;
+ faceCallButton.visible = true;
+}
function closeChatWindow() {
chatMode = 'menu';
// Clean up chat
if (currentChatWindow) {
@@ -497,8 +660,16 @@
showUserSelection();
LK.getSound('menuSelect').play();
return;
}
+ // Check if touching face camera call button
+ var fdx = x - 1024;
+ var fdy = y - 250;
+ if (Math.abs(fdx) < 175 && Math.abs(fdy) < 40) {
+ startVideoCall();
+ LK.getSound('menuSelect').play();
+ return;
+ }
}
// Check if touching start chat button
if (chatMode === 'userSelection' && startChatButton && selectedChatUsers.length > 0) {
var dx = x - 800;