Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User memphis_'s Avatar
    Join Date
    Mar 2003
    Posts
    7
    We are working to develop an action game (karatay type). for saving Jar file space, I want to extract charecter image Frames from a single File. Can any one give me any efficiant code snipet for doing this thing.
    2 - Also there are some strange behavior in the my game application. some times one charecter image loads well, but other not laoded or displayed. I guess it is due to some memory problems. but game does not throw any exception and run smoothly, and second player play in invisiable mode.

  2. #2
    Registered User sstasik's Avatar
    Join Date
    Mar 2003
    Posts
    2
    it is programming question rather then device related.

    usual technique is to compute position of needed fram and then do sth like:

    graphics.clipRect(xPos, yPos, spriteWidth, spriteHeight);
    graphics.drawImage(image,
    xPos - spriteWidth * (sequence[frame] % framesInRow),
    yPos - spriteHeight * (sequence[frame] / framesInRow),
    0);


    regards,

    Szymon

  3. #3
    Regular Contributor tinkezione's Avatar
    Join Date
    Mar 2003
    Location
    Helsinki.FI
    Posts
    112
    memphis,

    a little comment on Szymon's approach: calculating a modulus is veeeery slow and can harass your MIDlet performance in low performance environments like this. Instead, put all the frames into one long PNG file and Graphics.setClip from there accordingly. (I assume every frame is equal sized and the sequences for different animations are stored in some integer array? You can then use that integer as a base for processing your animation sequence with setClip, like animationFrame[whateverMoveIsThis][indexOfFramesInThisMove] * whateverIsTheWidthOfEachFrame, right?)

    Graphics.setClip(anim[move][fr] * frWidth, 0, (anim[move][fr]+1) * frameWidth - 1, frameHeight);

    Kind regards,
    Tinke / FN

    PS. Sorry for the double post.
    DRINK COFFEE - Do stupid things faster with more energy

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved