J2ME Image effects part 2: sliding transitions

After an explosive J2ME class, now it’s the time for sliding transition effects. With the following SlidingImage class you’ll be able to seamlessly add both SlideIn and SlideOut effects to your toooo static apps!

J2ME sliding transition effect screenshot

As usual, take a look at how this would appear in a real phone, and then proceed with the simple these 1,2,3 steps :)

  1. Download and include in your code the SlidingImage.java class
  2. Instantiate a new SlidingImage:
    SlidingImage image = new SlidingImage(

    These are the constructor arguments:

    • An Image object to be slided
    • The number of pieces of the sliding image
    • The type of slide, can be SlidingImage.SLIDE_IN or SlidingImage.SLIDE_OUT
  3. Start the sliding effect, specifying its direction and duration (in milliseconds):
    image.slide(Canvas.RIGHT, 3000);

    Direction can be one of Canvas properties UP, RIGHT, DOWN and LEFT.

  4. Now you can paint it simply specifying coordinates and an anchor, as usual:
    	100, 100,
    	Graphics.HCENTER | Graphics.VCENTER);
  5. If you remember ExplodingImage class, you can check if effect is ended with the public ended property:
    //effect-end related code
  6. If you want to reset the effect, also changing the sliding image pieces and effect type (slide in or out), you can use the reset() method:
    //to reset changing also slides and type properties
    image.reset(12, SlidingImage.SLIDE_IN);
    //otherwise, to simply reset:

You can download source code here:

Be Sociable, Share!