mirror of
https://github.com/kkhattabi213/megafonias-react.git
synced 2026-01-30 09:13:40 +00:00
boton colision
This commit is contained in:
BIN
public/audio/colision.m4a
Normal file
BIN
public/audio/colision.m4a
Normal file
Binary file not shown.
BIN
public/audio/colision.wav
Normal file
BIN
public/audio/colision.wav
Normal file
Binary file not shown.
@@ -64,4 +64,4 @@ body.light-theme {
|
||||
body.dark-theme {
|
||||
background-color: #343a40; /* Color de fondo oscuro */
|
||||
color: #f8f9fa; /* Color de texto claro */
|
||||
}
|
||||
}
|
||||
|
||||
12
src/App.js
12
src/App.js
@@ -103,6 +103,13 @@ function App() {
|
||||
}
|
||||
};
|
||||
|
||||
const reproducirColision = () => {
|
||||
const audioColision = new Audio('/audio/colision.wav');
|
||||
audioColision.play().catch(error => {
|
||||
console.error("Error al reproducir audio:", error);
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const cargarAudios = () => {
|
||||
// Preload audio files (optional but recommended)
|
||||
@@ -115,6 +122,7 @@ function App() {
|
||||
});
|
||||
|
||||
const audioVallecas = new Audio(`/audio/vallecas.wav`); // Preload new audio file
|
||||
const audioColision = new Audio(`/audio/colision.m4a`);
|
||||
};
|
||||
|
||||
cargarAudios();
|
||||
@@ -195,6 +203,10 @@ function App() {
|
||||
<button onClick={toggleTheme} className="btn btn-secondary mt-3">
|
||||
Cambiar tema a {theme === 'light' ? 'oscuro' : 'claro'}
|
||||
</button>
|
||||
|
||||
<button onClick={reproducirColision} className="btn btn-danger mt-3 fixed-bottom">
|
||||
Colisión
|
||||
</button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user