Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Client-side Scripting _ Need your help guys (simple problem)

Posted by: Saul Oct 25 2017, 04:01 AM

Hi everybody

Iam very new to HTML (proper Noob) so your knowledge would be much appreciated
anyway let me explain

Iam creating a site for my iphone
its very simple

1 image
1 javascript

Using the JavaScript from this Accelerometer ball demo, (as you tilt your phone the ball moves around the screen) Simple ye.

I need to restrict the ball to only move in the Red area, & i have no idea how to do this.
IPB Image

this is my html file
Attached File  index.html ( 2.36k ) Number of downloads: 654

Thanks guys

Posted by: pandy Oct 25 2017, 08:11 AM

Try setting h in function intit() to something else than the window height.

function init()
    ball = document.getElementById("ball");
     w = window.innerWidth;
     h = window.innerHeight;

Powered by Invision Power Board (
© Invision Power Services (