This is a question regarding changing the top property of an element in HTML.
I am trying to build a game which pans the background image horizontally and the object in question vertically.The game works properly on the desktop but on the iPhone,the top property isn’t changing dynamically.
This is the code where I am trying to set the top
blitzbot.bgPanValue.vy += blitzbot.bgPanValue.gravity;
blitzbot.bgPanValue.currentY -= blitzbot.bgPanValue.vy;
var cury = Math.round(blitzbot.bgPanValue.currentY);
document.getElementById("hotDog").style.top = -cury - 300 + "px";
I traced out the value of document.getElementById("hotDog").style.top and the values do change.However,the top is not getting set for hotDog on iPhone.
Best,
Harsha
Found out what the issue was!
There was a
background-positionproperty which was being used depending on some hitTests.Apparently,mobile safari has issues withbackground-position!