1
0

Refactor and enhance cat animation logic with random salto chance and improved heart explosion timing

This commit is contained in:
2025-05-26 05:14:12 +02:00
parent c001770ef1
commit c18c2b258a

View File

@@ -306,30 +306,57 @@ _bindMouseHold() {
// Bild auf joy.png setzen: // Bild auf joy.png setzen:
img.src = this.images.joy || this.images.default; img.src = this.images.joy || this.images.default;
// Nach oben springen und nach RECHTS rotieren: // 20% Chance auf Salto!
wrapper.style.transition = 'transform 0.6s cubic-bezier(.19,1,.22,1)'; const salto = Math.random() < 0.2;
wrapper.style.transform = 'translateY(-40px) rotate(12deg)';
this._spawnHearts(12); if (salto) {
// Salto: 360° Drehung
setTimeout(() => { wrapper.style.transition = 'transform 0.8s cubic-bezier(.19,1,.22,1)';
wrapper.style.transform = 'translateY(-40px) rotate(0deg)';
setTimeout(() => { setTimeout(() => {
// Rücksprung nach unten, zurückdrehen: wrapper.style.transition = 'transform 0.6s cubic-bezier(.19,1,.22,1)';
wrapper.style.transition = 'transform 0.8s cubic-bezier(.19,1,.22,1)'; wrapper.style.transform = 'translateY(-40px) rotate(360deg)';
wrapper.style.transform = 'translateY(0) rotate(0deg)';
img.src = this.images.mouthOpen || this.images.default;
setTimeout(() => { setTimeout(() => {
if (!this._pettingActive) { wrapper.style.transition = 'transform 0.8s cubic-bezier(.19,1,.22,1)';
this.img.src = this.images.default; wrapper.style.transform = 'translateY(0) rotate(0deg)';
} img.src = this.images.mouthOpen || this.images.default;
setTimeout(() => { setTimeout(() => {
wrapper.style.transition = origTransition || ''; if (!this._pettingActive) {
wrapper.style.transform = origTransform || ''; this.img.src = this.images.default;
if (typeof onFinish === 'function') onFinish(); }
}, 700); setTimeout(() => {
}, 2000); wrapper.style.transition = origTransition || '';
}, 2200); wrapper.style.transform = origTransform || '';
}, 400); if (typeof onFinish === 'function') onFinish();
}, 700);
}, 2000);
}, 600);
}, 400);
} else {
// Normale Joy-Animation: leicht drehen
wrapper.style.transition = 'transform 0.6s cubic-bezier(.19,1,.22,1)';
wrapper.style.transform = 'translateY(-40px) rotate(12deg)';
setTimeout(() => {
setTimeout(() => {
wrapper.style.transition = 'transform 0.8s cubic-bezier(.19,1,.22,1)';
wrapper.style.transform = 'translateY(0) rotate(0deg)';
img.src = this.images.mouthOpen || this.images.default;
setTimeout(() => {
if (!this._pettingActive) {
this.img.src = this.images.default;
}
setTimeout(() => {
wrapper.style.transition = origTransition || '';
wrapper.style.transform = origTransform || '';
if (typeof onFinish === 'function') onFinish();
}, 700);
}, 2000);
}, 2200);
}, 400);
}
// Herzchen-Explosion unabhängig vom Salto
this._spawnHearts(12);
} }
_spawnHearts(count = 10) { _spawnHearts(count = 10) {