×
Namespaces

Variants
Actions
Revision as of 12:55, 27 June 2013 by Tomi_ (Talk | contribs)

Creating Simple Animations with Java ME

From Nokia Developer Wiki
Jump to: navigation, search

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:

        if (_animation.start(from, to, ANIMATION_DURATION, EASING_CURVE))
{
// Animation successfully started!
}
else {
// Failed to start the animation! Handle this situation gracefully.
_animation.stop();
}

Summary

171 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.

×