User prompt
Agrega un texto arriba de los dados para que avisé cuando se puede lanzar y cuando están cambiando. También agrega un contador con segundos y decimales 1.00s (que se actualice a tiempo) al finalizar el cambio antes de poder lanzar ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Haz que se tenga que esperar mínimo 1 segundos antes de hacer otro tiro
User prompt
Tiñe de un color amarillo suave los dados iguales y con colores random los dados iguales pero que son inferiores al grupo grande ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Agrega un texto en la parte superior centrado diciendo 0/8. El cero representa la cantidad de dados iguales (solo aplica el que mas se repita. Ej: si hay 2 dados de 4 y 4 dados de 1 solo contará el grupo más grande)
User prompt
El sonido no se escucha, haz que la lógica de sonido este por separado
User prompt
Agrega un sonido cada que los dados cambian
User prompt
Haz que suene roll cada que los dados se tiran (haz que se escuche un máximo de 4 roll sound para evitar sonidos fuertes)
User prompt
Agrega un efecto de rebote cada vez que cabía ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Arregla el error que hace que el asset de dado desaparezca por momentos, haz que el cambio entre asset no se vea con lagasos (no tweet plugin)
User prompt
Arregla el error que hace que el asset de dado desaparezca por momentos, haz que el cambio entre asset no se vea con lagasos (no tweet plugin)
User prompt
Arregla el error que hace que el asset de dado desaparezca por momentos, haz que el cambio entre asset no se vea con lagasos ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Arregla el error que hace que no cambie los asset con los valores
User prompt
Haz que el objeto no se borre y cree otro, que simplemente cambie asset
User prompt
Agrega un evento llamado "lanzamiento" con un activador bolano. Haz que cada dado cambie aleatoriamente entre 6 a 12 veces empezando rápido y terminando cada vez más lento hasta finalizar. Una vez el último dado para se puede volver a tirar (sin tweet plugin, ni comentarios)
User prompt
Sin tweet plugin
User prompt
Agrega un evento llamado "lanzamiento" con un activador bolano. Haz que cada dado cambie aleatoriamente entre 6 a 12 veces empezando rápido y terminando cada vez más lento hasta finalizar. Una vez el último dado para se puede volver a tirar ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Quiero que al tocar la pantalla los números cambien aleatoriamente
Code edit (1 edits merged)
Please save this source code
User prompt
Asigna un asset diferente para cada valor del dado
User prompt
Agrega a cada dado una varisble numérica llamada "valor"
User prompt
Agrega una variable Number a cada dado
User prompt
Agrega una variable number a cada dado, haz que cada segundo de la animación roll su variable cambie aleatorio en un rango entre 1 a 6, haz que su aset cambie durante la animación correspondiente la variable con el número del dado ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Agrega una flag para permitir el rodamiento una vez finaliza la animación y pasa un segundo ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Agrega una animación al tocar la pantalla donde los dados dan 3 giros en su propio eje ↪💡 Consider importing and using the following plugins: @upit/tween.v1
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Dice = Container.expand(function () { var self = Container.call(this); // Add numeric variable valor self.valor = 1; // Add rolling animation variables self.isRolling = false; self.rollCount = 0; self.rollTarget = 0; self.rollTimer = 0; var diceGraphics = self.attachAsset('Dice' + self.valor, { anchorX: 0.5, anchorY: 0.5 }); // Method to update dice visual based on valor self.updateVisual = function () { // Create new graphics based on valor first var newGraphics = self.attachAsset('Dice' + self.valor, { anchorX: 0.5, anchorY: 0.5 }); // Remove old graphics after new one is created self.removeChild(diceGraphics); // Update reference to new graphics diceGraphics = newGraphics; // Add bounce effect when value changes during rolling if (self.isRolling) { diceGraphics.scaleX = 1; diceGraphics.scaleY = 1; tween(diceGraphics, { scaleX: 1.2, scaleY: 1.2 }, { duration: 100, easing: tween.bounceOut, onFinish: function onFinish() { tween(diceGraphics, { scaleX: 1, scaleY: 1 }, { duration: 100, easing: tween.bounceOut }); } }); } }; // Method to start rolling animation self.startRoll = function () { self.isRolling = true; self.rollCount = 0; self.rollTarget = Math.floor(Math.random() * 7) + 6; // 6 to 12 rolls self.rollTimer = 0; }; // Update method for rolling animation self.update = function () { if (self.isRolling) { var rollSpeed = Math.floor(self.rollCount * 1.5) + 3; // Start fast, get slower if (self.rollTimer >= rollSpeed) { self.valor = Math.floor(Math.random() * 6) + 1; self.updateVisual(); self.rollCount++; self.rollTimer = 0; if (self.rollCount >= self.rollTarget) { self.isRolling = false; } } else { self.rollTimer++; } } }; return self; }); /**** * Initialize Game ****/ // Create array to hold all dice var game = new LK.Game({ backgroundColor: 0xFFFFFF }); /**** * Game Code ****/ // Create array to hold all dice var diceArray = []; // Add lanzamiento boolean variable var lanzamiento = false; // Calculate center positions for two columns var centerX = 2048 / 2; var centerY = 2732 / 2; var columnSpacing = 330; // Space between columns var rowSpacing = 300; // Space between rows // Create 8 dice in two columns (4 rows each) for (var col = 0; col < 2; col++) { for (var row = 0; row < 4; row++) { var dice = new Dice(); // Assign random valor from 1 to 6 dice.valor = Math.floor(Math.random() * 6) + 1; // Update visual based on valor dice.updateVisual(); // Position dice in grid dice.x = centerX + (col - 0.5) * columnSpacing; dice.y = centerY + (row - 1.5) * rowSpacing; // Add to game and array game.addChild(dice); diceArray.push(dice); } // Game update method to handle dice rolling game.update = function () { // Check if all dice have finished rolling if (lanzamiento) { var allFinished = true; for (var i = 0; i < diceArray.length; i++) { if (diceArray[i].isRolling) { allFinished = false; break; } } // Reset lanzamiento when all dice are done if (allFinished) { lanzamiento = false; } } }; // Add screen tap handler for lanzamiento event game.down = function (x, y, obj) { // Only allow new roll if not currently rolling if (!lanzamiento) { lanzamiento = true; // Start rolling animation for all dice for (var i = 0; i < diceArray.length; i++) { diceArray[i].startRoll(); } } }; }
===================================================================
--- original.js
+++ change.js
@@ -1,5 +1,10 @@
/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
* Classes
****/
var Dice = Container.expand(function () {
var self = Container.call(this);
@@ -24,8 +29,29 @@
// Remove old graphics after new one is created
self.removeChild(diceGraphics);
// Update reference to new graphics
diceGraphics = newGraphics;
+ // Add bounce effect when value changes during rolling
+ if (self.isRolling) {
+ diceGraphics.scaleX = 1;
+ diceGraphics.scaleY = 1;
+ tween(diceGraphics, {
+ scaleX: 1.2,
+ scaleY: 1.2
+ }, {
+ duration: 100,
+ easing: tween.bounceOut,
+ onFinish: function onFinish() {
+ tween(diceGraphics, {
+ scaleX: 1,
+ scaleY: 1
+ }, {
+ duration: 100,
+ easing: tween.bounceOut
+ });
+ }
+ });
+ }
};
// Method to start rolling animation
self.startRoll = function () {
self.isRolling = true;