Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

(Difference between revisions)

Creating Simple Animations with Java ME

From Wiki
Jump to: navigation, search
Tomi_ (Talk | contribs)
m (Tomi -)
Tomi_ (Talk | contribs)
m (Tomi -)
Line 38: Line 38:
 
</gallery>
 
</gallery>
  
=== Usage ===
+
== Usage ==
  
 
<code java>
 
<code java>

Revision as of 13:12, 27 June 2013

This article explains how to ...

Article Metadata
CompatibilityArticle
Created: (28 Jun 2013)
Last edited: Tomi_ (27 Jun 2013)

Contents

Introduction

Implementation

Architecture

Animation-fw-architecture.png

Easing curves

Usage

public class MyCanvas
extends Canvas
implements AnimationListener
{
// Constants
...
private static final int ANIMATION_DURATION = 500;
private static final int EASING_CURVE = IntAnimation.EASING_CURVE_INOUTQUAD;
 
// Members
...
private IntAnimation _animation = null;
...
 
/**
* Constructor.
*/

public MyCanvas() {
super();
...
_animation = new IntAnimation();
_animation.setListener(this);
...
    /**
* @see AnimationListener#onAnimatedValueChanged(int)
*/

public void onAnimatedValueChanged(int value) {
// Handle the value
...
repaint();
}
 
/**
* @see AnimationListener#onAnimationStateChanged(int)
*/

public void onAnimationStateChanged(int state) {
switch (state) {
case IntAnimation.STATE_RUNNING:
...
break;
case IntAnimation.STATE_STOPPED:
...
break;
case IntAnimation.STATE_FINISHED:
...
break;
default:
break;
}
}

Then just let it rip:

boolean started = _animation.start(from, to, ANIMATION_DURATION, EASING_CURVE))
 
if (!started) {
// Failed to start the animation! Handle this situation gracefully - maybe by just jumping to the "to" point.
}

Summary

246 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×