Back to project page LucyTheMoocher.
The source code is released under:
MIT License
If you think the Android project LucyTheMoocher listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.lucythemoocher.graphics; //w w w. j a v a 2s. c o m public class ActorDrawer { private Animation anim_; private boolean persistenceEnabled_; private PersistentEffect persistentEffect_; private int persistenceTime_; public ActorDrawer() { anim_ = new Animation(); persistenceEnabled_ = false; persistentEffect_ = new PersistentEffect(); } /** * Draw the actor */ public void draw(int x, int y) { if (persistenceEnabled_) { persistentEffect_.add(getAnim().getCurrentImage(), x, y, persistenceTime_); } else { // only draw if there's no persistence getAnim().draw(x, y); } // we draw even if it's disable to draw the remaining persistent pic persistentEffect_.draw(); } public void update() { getAnim().update(); // we update even if disabled to update the remaining persistent pic persistentEffect_.update(); } public void initializeAnimation(int resource) { getAnim().initialize(resource); } public void setAnimation(int tab[], float period) { getAnim().setAnimation(tab, period); } public void enablePersistence(int persistenceTime) { persistenceEnabled_ = true; persistenceTime_ = persistenceTime; persistentEffect_.reset(); } public void disablePersistence() { persistenceEnabled_ = false; } public Animation getAnim() { return anim_; } }