Rob,
The ball for example does not roll in the direction of the tilt. If i tilt down right it goes up. Also it becomes light like in the sky flying and goes in diff direction.
The app is from the sample but i have modified my walls and add balls pictures that i made. Basically i used the tilt function…
I hope you can provide some hints
Regards
Abdul
i am not sure what is wrong in this function… do i need to change some values based on build settings.
My aim is to make three balls at a time( each has a number drawn on it) and based on the number shown , the player should move the ball using tilt capabilities until the correct ball is out of the screen, so the player can go to the next number and so on.
Brent really needs to chime in on this since he’s more Physics that me, but I would think the physics simulation would not like having gravity changed that often. And I’m not sure that’s going to give you the effect you want anyway.
You’re only going to get the balls to stop moving when the device is perfectly flat. You have to tilt it away from you to move things up. This would be pretty uncomfortable for a player to do. You need to take the delta numbers from that and apply the results as some impulse or force to your balls.
I confirmed with the engineers, and essentially, the accelerometer values are always relative to portrait on both iOS and Android. So, if your app is landscape, you’ll need to compensate by 90 degrees.
It’s not so much a direct “90” or “-90” application to the value. Instead, you need to effectively make the Y gravity be the X gravity, and possibly negate the value too. For example, if you had -9.8 m/s² being applied from the top (in portrait), and you rotate the device, that value is now being applied to the left (or right) of that object in regards to the accelerometer. So, you need to swap those values so that it’s being applied to the “new top” of the object in landscape.
i swapped event.yGravity with event.xGravity and negate the event.xGravity… I am not sure I understand the concept behind it but it works… also i changed the number from 9.8 to 15 for both side just to make it move faster … I think Corona SDK should understand the landscape changes without changing the code since corona can understand the landscape and portrait orientation. This is my personal opinion. I might be wrong but I really struggled getting it to work because every change must do a build and test it in a real device as simulator cant show you the result of tilt event,
Rob,
The ball for example does not roll in the direction of the tilt. If i tilt down right it goes up. Also it becomes light like in the sky flying and goes in diff direction.
The app is from the sample but i have modified my walls and add balls pictures that i made. Basically i used the tilt function…
I hope you can provide some hints
Regards
Abdul
i am not sure what is wrong in this function… do i need to change some values based on build settings.
My aim is to make three balls at a time( each has a number drawn on it) and based on the number shown , the player should move the ball using tilt capabilities until the correct ball is out of the screen, so the player can go to the next number and so on.