User prompt
Aumenta el tamaño de la cuadricula un 60%
User prompt
aumenta su tamaño un 60% ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
crea un grid 9*9 en el centro de la pantalla con un espaciado de 10 pixeles entre cada uno
Code edit (1 edits merged)
Please save this source code
User prompt
Bubble Popper: Tap 'n' Blast
Initial prompt
hi
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var Grid = Container.expand(function () { var self = Container.call(this); // Grid configuration self.rows = 9; self.cols = 9; self.cellSize = 100; // Size of each grid cell self.spacing = 10; // Spacing between cells self.cells = []; // Store references to all cells // Calculate total grid dimensions self.gridWidth = self.cellSize * self.cols + self.spacing * (self.cols - 1); self.gridHeight = self.cellSize * self.rows + self.spacing * (self.rows - 1); // Create cells for the grid self.createGrid = function () { for (var row = 0; row < self.rows; row++) { for (var col = 0; col < self.cols; col++) { var cell = self.attachAsset('cuadricula', { anchorX: 0, anchorY: 0 }); // Position the cell with spacing cell.x = col * (self.cellSize + self.spacing); cell.y = row * (self.cellSize + self.spacing); // Store cell reference self.cells.push(cell); } } }; // Method to resize the grid cells self.resizeGrid = function (scaleFactor, duration) { var newCellSize = self.cellSize * scaleFactor; var oldCellSize = self.cellSize; // Update cell size self.cellSize = newCellSize; // Recalculate grid dimensions self.gridWidth = self.cellSize * self.cols + self.spacing * (self.cols - 1); self.gridHeight = self.cellSize * self.rows + self.spacing * (self.rows - 1); // Animate each cell to its new size and position for (var i = 0; i < self.cells.length; i++) { var cell = self.cells[i]; var row = Math.floor(i / self.cols); var col = i % self.cols; // Animate the size and position tween(cell, { width: newCellSize, height: newCellSize, x: col * (newCellSize + self.spacing), y: row * (newCellSize + self.spacing) }, { duration: duration || 800, easing: tween.easeInOut }); } // Re-center the grid in the game var centerX = (2048 - self.gridWidth) / 2; var centerY = (2732 - self.gridHeight) / 2; // Animate the grid to center it tween(self, { x: centerX, y: centerY }, { duration: duration || 800, easing: tween.easeInOut }); }; // Initialize the grid self.createGrid(); return self; }); /**** * Initialize Game ****/ // Create a new grid var game = new LK.Game({ backgroundColor: 0xF4FFFF }); /**** * Game Code ****/ // Create a new grid var grid = new Grid(); // Center the grid on the screen grid.x = (2048 - grid.gridWidth) / 2; grid.y = (2732 - grid.gridHeight) / 2; // Add the grid to the game game.addChild(grid); // Increase grid size by 60% after a short delay LK.setTimeout(function () { grid.resizeGrid(1.6, 1000); // Increase size by 60% with 1 second animation }, 500);
===================================================================
--- original.js
+++ change.js
@@ -1,5 +1,10 @@
/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
* Classes
****/
var Grid = Container.expand(function () {
var self = Container.call(this);
@@ -7,8 +12,9 @@
self.rows = 9;
self.cols = 9;
self.cellSize = 100; // Size of each grid cell
self.spacing = 10; // Spacing between cells
+ self.cells = []; // Store references to all cells
// Calculate total grid dimensions
self.gridWidth = self.cellSize * self.cols + self.spacing * (self.cols - 1);
self.gridHeight = self.cellSize * self.rows + self.spacing * (self.rows - 1);
// Create cells for the grid
@@ -21,11 +27,50 @@
});
// Position the cell with spacing
cell.x = col * (self.cellSize + self.spacing);
cell.y = row * (self.cellSize + self.spacing);
+ // Store cell reference
+ self.cells.push(cell);
}
}
};
+ // Method to resize the grid cells
+ self.resizeGrid = function (scaleFactor, duration) {
+ var newCellSize = self.cellSize * scaleFactor;
+ var oldCellSize = self.cellSize;
+ // Update cell size
+ self.cellSize = newCellSize;
+ // Recalculate grid dimensions
+ self.gridWidth = self.cellSize * self.cols + self.spacing * (self.cols - 1);
+ self.gridHeight = self.cellSize * self.rows + self.spacing * (self.rows - 1);
+ // Animate each cell to its new size and position
+ for (var i = 0; i < self.cells.length; i++) {
+ var cell = self.cells[i];
+ var row = Math.floor(i / self.cols);
+ var col = i % self.cols;
+ // Animate the size and position
+ tween(cell, {
+ width: newCellSize,
+ height: newCellSize,
+ x: col * (newCellSize + self.spacing),
+ y: row * (newCellSize + self.spacing)
+ }, {
+ duration: duration || 800,
+ easing: tween.easeInOut
+ });
+ }
+ // Re-center the grid in the game
+ var centerX = (2048 - self.gridWidth) / 2;
+ var centerY = (2732 - self.gridHeight) / 2;
+ // Animate the grid to center it
+ tween(self, {
+ x: centerX,
+ y: centerY
+ }, {
+ duration: duration || 800,
+ easing: tween.easeInOut
+ });
+ };
// Initialize the grid
self.createGrid();
return self;
});
@@ -46,5 +91,9 @@
// Center the grid on the screen
grid.x = (2048 - grid.gridWidth) / 2;
grid.y = (2732 - grid.gridHeight) / 2;
// Add the grid to the game
-game.addChild(grid);
\ No newline at end of file
+game.addChild(grid);
+// Increase grid size by 60% after a short delay
+LK.setTimeout(function () {
+ grid.resizeGrid(1.6, 1000); // Increase size by 60% with 1 second animation
+}, 500);
\ No newline at end of file
la figura de una casa color blanca simple para una interfaz. In-Game asset. 2d. High contrast. No shadows
haz el fondo color morado
circular check logo. In-Game asset. 2d. High contrast. No shadows
Cuadrado con los bordes redondeado negro. In-Game asset. 2d. High contrast. No shadows
hazlo un gris claro
Que sea blanco
Que sea blanco