Copy link to clipboard
Copied
I don't know how to use Accelerometer and to have smooth animation of that object(vector), I just need it to go to one side of the screen and to another when mobile device is moved in that direction (left or right).
I used acceleromete basics but besides its very choppy movements, it goes off the screen and doesn't stays inside.
Thanks
Copy link to clipboard
Copied
Please provide some code examples of how you're utilizing the accelerometer.
Aside that you're most likely not moving objects on a fast enough speed (either ENTER_FRAME with some custom easing or using a Twen engine like TweenLite ( http://www.greensock.com )).
Copy link to clipboard
Copied
I'm just starting to use it don't have any code yet except that codesnippet, so if you could provide me one example that would be great. I just need one object moving from left to right without going off the screen.
thanks!
Copy link to clipboard
Copied
Here you can find some really useful tricks to enhance performance of flash-tweens for mobile devices.
Especially this tip should be related to your problem:
Use cacheAsBitmap and cacheAsBitmapMatrix
If you have vector object that you’d like to animate in your project remember to cache them and then animate; remember also to set your application with GPU acceleration and you can see a really good performance with this technique.
Avoid to cache objects that you need to remove from display list, it will be so expensive for your memory.
Here is a video from Adobe with code examples that shows exactly the problem you are facing.
Copy link to clipboard
Copied
There's a million examples on the net about using the Accelerometer. The original one I started with a very long time ago can be found here:
AIR2 Accelerometer Game Example
It's about 180 lines of code and is a complete game using the accelerometer with some custom coded easing (very simple stuff). No extra classes needed, very easy to read code. It's very old but still works fine and I think it hits your basic needs perfectly. The newer tutorials do exactly the same thing but use extra libraries to smooth movement. I try to stick to less libraries whenever possible.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now