Moving a image around using the Accelerometer
Can anybody tell me where i am going wrong with this. the square dosent move around the screen liked i thought.
var win = Titanium.UI.currentWindow;
var item = Titanium.UI.createView({
backgroundColor:'#336699',
top:300,
left:50,
height:50,
width:50
});
win.add(item);
Titanium.Accelerometer.addEventListener('update',function(e)
{
item.animate({center:{x:e.x,y:e.y,z:e.z}, duration:1});
});
1 Answer
-
I don't think the accelerometer values are coordinate values. Display the values you're getting from the accelerometer and you'll see what I mean.