Position pokeball burst effect on actual Pokemon element instead of hardcoded coordinates
This commit is contained in:
1 parent
fa724a8911
commit
143bd68f5b
1 file changed
+4
-2
@@ -1338,10 +1338,12 @@ class Game {
|
|||||||
catchScreen.appendChild(ball);
|
catchScreen.appendChild(ball);
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
const pokeRect = pokemonEl.getBoundingClientRect();
|
||||||
|
const screenRect = catchScreen.getBoundingClientRect();
|
||||||
const burst = document.createElement('div');
|
const burst = document.createElement('div');
|
||||||
burst.className = 'pokeball-burst';
|
burst.className = 'pokeball-burst';
|
||||||
burst.style.left = '50%';
|
burst.style.left = (pokeRect.left - screenRect.left + pokeRect.width / 2) + 'px';
|
||||||
burst.style.top = '25%';
|
burst.style.top = (pokeRect.top - screenRect.top + pokeRect.height / 2) + 'px';
|
||||||
catchScreen.appendChild(burst);
|
catchScreen.appendChild(burst);
|
||||||
|
|
||||||
ball.remove();
|
ball.remove();
|
||||||
|
|||||||
Reference in new issue
Block a user