midp 1.0 animation

Hello, i’m trying to implement basic animation using midp 1.0.

i have one big image containing all of the animation frames of a single character, i’m trying to find a way to choose to render a specific area of the image (the current frame) onto the Graphics.

i looked at midp 1.0 specs and didn’t find anything that does that (the only related function was Graphics.drawImage(…) which draws the entire image :confused:

should i create new Images for each of the frames? sounds wasting…

any help will be appreciated :slight_smile:

This is what I use:

  public void drawSubImage(Graphics g,Image src, int x, int y, int subx, int suby, int width, int height)
    {
    g.setClip(x,y,width,height);
    g.drawImage(src,(x-subx),(y-suby),Graphics.TOP|Graphics.LEFT);
    
    // added the +40 here because we may be drawing to an offsceen
    // which has +1 tile and may have a partial tile each = 20
    g.setClip(0,0,scrx+40,scry+40);
    //g.setClip(0,0,scrx,scry);
    }

Where g is the screen/image you are drawing into. src is the image with all your animation frames. x,y are the onscreen location and subx,suby are the location within your animation frames.

Wood

It should be noted that Samsung phones have weird issues with setClip and I have also heard (and seen) similar problems with a Sony phone.

thanks!