Im having trouble smoothing out a hand made animation, specifically the logo
on my site at www.users.on.net/~rossn
The spinning sections of the logo are redrawn every frame rather a pair of
rotating images, because rotating is slow and sometimes looks bad with poor
rotation algorithms on other graphics libraries - the same code has been
used over and over with a few different libraries now...
I currently have a Handler which is sending a reoccuring repaint call to
recalculate and redraw the lines. For the most part this works, but
occasionally it becomes a bit choppy. I assume this is because other jobs
are being processed by the same looper? Garbach collection maybe? Is it best
to try and pull the redraw loop out into a seperate thread/Looper? I should
note that Im not too keen on doing that because I'll be using the same setup
later with game animations - the world will need to be updated between
screen refreshes making syncing two threads a lot of hard work when one
thread will do.
Anyway here is code, with unrelated stuff removed and some names changed...
The MyView class onDraw(), which is not shown, recalculates and redraws the
lines of the logo on the view.
public class MyClass extends Activity{
MyView view;
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
view = new MyView(this);
this.setContentView(view);
new RefreshHandler().run();
}
class RefreshHandler extends Handler implements Runnable{
@Override
public void run(){
view.invalidate();
this.post(this);
}
}
}
-Numeron
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en