स्क्रीनशॉट/बिटमैप दृष्टिकोण के लिए एक विकल्प के रूप में छवियों की स्थिति बदलने के लिए समन्वय ...
एक क्लिपिंग क्षेत्र को धक्का देने और ऑफ़सेट ड्राइंग करने के लिए Graphics.pushContext (..)। सर्वोत्तम परिणामों के लिए, आप एक रननेबल में संक्रमण करना चाहते हैं, और इवेंट लॉक पर सिंक्रनाइज़ करना चाहते हैं। इससे यह सुनिश्चित होगा कि आपकी स्क्रीन को संक्रमण के बीच में खारिज कर दिया जा सके।
असहज उदाहरण:
class TransitionScreen extends Screen {
private int transitionOffset;
private boolean isTransitionHorizontal;
private ScreenTransition currentTransition;
public TransitionScreen(boolean isTransitionHorizontal) {
this.isTransitionHorizontal = isTransitionHorizontal;
transitionOffset = getTransitionMaximum(); // So the screen starts offset
}
protected void paint(Graphics graphics) {
// use transitionOffset as x or y depending on isTransitionHorizontal
graphics.pushContext(...);
}
protected void onExposed() {
transitionToOffset(0);
}
protected void onObscured() {
int target = getTransitionMaximum();
transitionToOffset(target);
}
private int getTransitionMaximum() {
return isTransitionHorizontal ? Display.getWidth() : Display.getHeight();
}
private void transitionToOffset(int target) {
if (currentTransition != null) {
currentTransition.stop();
}
currentTransition = new ScreenTransition(target);
getApplication().invokeLater(currentTransition);
}
}
class ScreenTransition implements Runnable {
private boolean animating;
private int target;
public ScreenTransitionUpdater(int target) {
this.target = target;
}
public void stop() {
animating = false;
}
public void run() {
while(animating) {
Object eventLock = getApplication().getEventLock();
synchronized(eventLock) {
// Interpolate myOffset to target
// Set animating = false if myOffset = target
invalidate();
}
}
}
}
के रूप में अस्थिर एनिमेट के रूप में यह इस मंच पर ध्यान नहीं दिया जाता चिह्नित करने के लिए कोई ज़रूरत नहीं।
स्रोत
2010-07-22 01:10:11
उत्तर के लिए धन्यवाद, उम्मीद है कि अन्य भी सहायक पा सकते हैं। – dickyj