J2me sprite animation

Could someone please help me? I need a simple j2me program. I needed to display on my phone a simple sprite animation.
Thank you!!!

No. We realise that would make it easy for you, whichis precisely why we are not going to do it.
jugheadwhat exactly is that supposed to mean? Go on then, give him some 'sample' code, that will really help him learn. The ONLY way to learn is to teach yourself, and build associations for yourself. If you just use someone else's code (and sample code will just be used like that), then how are you going to do that?

Similar Messages

  • J2ME - Sprite Animation example

    Hi i am new to J2ME programming and was wondering if there is a simple animation example/tutorial showing the use of sprites or an animated images the one show here on the java site was a little bit to complex for a beginning developer. Your help would be greatly appreciated.
    Thanks
    sengaste

    e-mail me to [email protected]
    and i give you an example

  • Issues when creating sprite animations. [was: Adobe CC please help!]

    I was watching a tutorial on how to create sprite animations when I ran into a little bit of a problem. I was trying to animate a koopa walking, but when I viewed the results the rest of the stuff disappeared! It was for CS6, but It wasn't to different.

    Matt421421 wrote:
    Dude, The title and the community. Open your eyes.
    You did not answer the question with a program name... this is the general Cloud forum
    Provide the name of the program you are using so a Moderator may move this message to the correct program forum
    This Cloud forum is not about help with program problems... a program would be Photoshop or Lighroom or Muse or ???

  • Character (sprite) animation

    What is the best way to handle character animation on the iPhone.
    Is using the UIImageView method the best to handle simple sprite animation using a number of PNG's.
    Is there a limit to the number of PNG images you should use?
    Also what is the best way to handle simple effects like zoom and pan, on a block of animation?
    Can a block of animation follow a curved path. e.g. a character walk cycle moving over a hill.
    I appreciate any response. I have a background in 2D animation and need some direction to how best to create animations on the iPhone and also what limitations I am up against.
    Thanks, Steve

    Okay, that is something different. I misunderstood what you meant by 'animation'.
    Moving 2D sprites in a game is done by creating a virtual model of the game world in the code that represents game objects by their positions in 2D space and their "movement" as a numerical velocity vector that specifies the number of pixels that the object should move per unit time. Time is simulated by updating the objects' position and redrawing the screen at some fixed time interval (the frame rate) determined by a timer.
    Here is a simple ball animation sample that assumes you have a 48x48 pixel image named ball.png. It creates a UIView subclass that should be loaded by the AppDelegate class.
    The header:
    #import <UIKit/UIKit.h>
    typedef struct
    CGFloat x;
    CGFloat y;
    } Vector2D;
    typedef struct
    Vector2D position;
    Vector2D velocity;
    } Sprite;
    @interface GameWorld : UIView {
    Sprite ball;
    UIImageView *ballImage;
    @end
    and the implementation:
    #import "GameWorld.h"
    #define kDotRadius 24
    @implementation GameWorld
    - (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
    [UIApplication sharedApplication].statusBarHidden = YES;
    ball.position.x = 200.0;
    ball.position.y = 300.0;
    ball.velocity.x = 3.0;
    ball.velocity.y = -3.0;
    ballImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ball.png"]];
    [self addSubview:ballImage];
    [NSTimer scheduledTimerWithTimeInterval:(1.0 /30.0) target:self selector:@selector(update) userInfo:nil repeats:YES];
    return self;
    -(void)update {
    if(ball.position.x - kDotRadius <= self.bounds.origin.x || ball.position.x + kDotRadius >= self.bounds.size.width)
    ball.velocity.x *= -1.0; //negate to reverse direction
    if(ball.position.y -kDotRadius <= self.bounds.origin.y || ball.position.y + kDotRadius >= self.bounds.size.height)
    ball.velocity.y *= -1.0;
    //commit to changes
    ball.position.x += ball.velocity.x;
    ball.position.y += ball.velocity.y;
    [self setNeedsDisplay];//refresh the view
    - (void)drawRect:(CGRect)rect {
    ballImage.center = CGPointMake(ball.position.x, ball.position.y);
    - (void)dealloc {
    [super dealloc];
    @end
    So it is the UIImageView's center property that is used to create the movement of the image view across the screen. This could be done directly, but the use of C structs (Vector2D and Sprite) make the code easier to read. The center property is updated only at the moment when the screen redraw occurs.

  • Best way to handle Sprite animation

    Hi all,
    Comments on overheads (memory/performance) on the following techniques?
    These are overly simplified, but you get the idea?
    Bitmap.visible
    // Assume we have a bunch of sprites already in memory as bitmap data
    var spriteData : Vector.<BitmapData>;
    // Now we create a sprite for each 'frame' of animation
    var bitmaps : Vector.<Bitmap> = new Vector.<Bitmap>();
    var bitmap : Bitmap;
    for (var i:int=0; i<spriteData.length; i++){
         bitmap = new Bitmap( spriteData[i] );
         addChild(bitmap);
         bitmaps.push(bitmap);
         bitmap.visible = false;
    // Now when we animate we simply set bitmaps visiblity
    public function gotoAndStop( frame : int ):void{
         bitmaps[ currentFrame ].visible = false;
         currentFrame = frame;
         bitmaps[ currentFrame ].visible = true;
    BitmapData replacement
    // Assume we have a bunch of sprites already in memory as bitmap data
    var spriteData : Vector.<BitmapData>;
    // Now we create a single sprite
    var bitmap : Bitmap;
    addChild(bitmap);
    // Now when we animate we swap bitmap data
    public function gotoAndStop( frame : int ):void{
         bitmap.bitmapData = spriteData[ frame ];
    I haven't performed this test on mobile yet - just wanted to get thoughts first.  Obviously if the animation has a lot of frames then the top one has a huge overhead, but is there a performance hit to swapping the bitmapData of a bitmap?
    Cheers,
    Peter

    This page has a good review that may be helpful:
    http://blog.starnut.com/flash-to-ios-performance-tests/

  • Frame(sprite) animation delay problem

    import javax.microedition.lcdui.*;
    import javax.microedition.lcdui.game.*;
    public class ExampleTrialCanvas extends GameCanvas implements Runnable {
    private boolean isPlay; // Game Loop runs when isPlay is true
    private long delay; // To give thread consistency
    private int currentX, currentY; // To hold current position of the 'X'
    private int width; // To hold screen width
    private int height; // To hold screen height
    // Sprites to be used
    // private Sprite playerSprite;
    private Sprite backgroundSprite;
    private Sprite playerSprite;
    //private int i;
    // Layer Manager
    private LayerManager layerManager;
    // Constructor and initialization
    public ExampleTrialCanvas() throws Exception {
    super(true);
    width = getWidth();
    height = getHeight();
    currentX = 64;
    currentY = 150;
    delay = 100;
    // Load Images to Sprites
    Image playerImage = Image.createImage("/transparent.png");
    playerSprite = new Sprite (playerImage,32,32);
    Image backgroundImage = Image.createImage("/gillete.png");
    backgroundSprite = new Sprite(backgroundImage);
    layerManager = new LayerManager();
    layerManager.append(playerSprite);
    layerManager.append(backgroundSprite);
    // Automatically start thread for game loop
    long now, prev_time_moved;
    public void init(){
    now = System.currentTimeMillis();
    prev_time_moved = now;
    public void start() {
    isPlay = true;
    Thread t = new Thread(this);
    t.start();
    public void stop() { isPlay = false; }
    // Main Game Loop
    public void run() {
    Graphics g = getGraphics();
    while (isPlay == true) {
    input();
              drawScreen(g);
    try { Thread.sleep(delay); }
    catch (InterruptedException ie) {}
    // Method to Handle User Inputs
    private void input()
    int keyStates = getKeyStates();
    playerSprite.setFrame(0);
    // Up
    if ((keyStates & UP_PRESSED) != 0) {
         for(int i=0;i<5;i++)
         playerSprite.setFrame(i);
    // Method to Display Graphics
    private void drawScreen(Graphics g) {
    // updating player sprite position
    playerSprite.setPosition(currentX,currentY);
    // display all layers
    layerManager.paint(g,0,0);
    layerManager.setViewWindow(55,20,180,180);
    //layerManager.paint(g,20,20);
    flushGraphics();
    We want, on right click botton press the frame should animate.
    We have a player with 5 different poses, kicking a ball, "image width is 160, height is 32".
    the problem is that, the player does move through allthe frames. he starts from 0th p\frame and directly end at the last frame, withopur any delay between frames.
    we have used the for loop as follows.
    if ((keyStates & UP_PRESSED) != 0) {
         for(int i=0;i<5;i++)
         playerSprite.setFrame(i);
    we want a delay code between all the frames.

    Maybe this will help you!
    btnSignIn.addActionListener(new ActionListener()     
                                  public void actionPerformed(ActionEvent e)
                                      //display the glasspane first
                                      setGlassPane(new MyGlassPane(newAnimatedIcon("images/LoginWaitingIcon.png")));
                                      getupGlasPane.setVisible(true);        //expected the glassPane shows (it does), and the animation starts (it doesnt)
                                      Thread t1 = new Thread(new Runnable()    //The animation only starts when this thread finished
                                            public void run()
                                                 //DO THE REST
    t1.start();
    t1.join();
    setupGlasPane(false);   //finish, turning off
                       });

  • Sprite animation with double buffering

    Hello, I am writing a game. I am not using swing. Just awt.
    I have several books I am looking at right now. One uses the
    BufferedImage class to create a buffered sprite. The other book instead uses the Image class to impliment double buffering. So, I am really confused now. I do not know if I should use the BufferedImage class or the Image class. Note that
    Please help. Which method is the best to use?
    Val

    These links may assist you in full-screen animation with double-buffering:
    http://www.sys-con.com/java/article.cfm?id=1893
    http://www.meatfighter.com/meat.pdf
    - Mike

  • Troulble slowing down sprite animations

    Hi guys! Well, I looked all over but couldn't find an answer. What I want to do is slow down the animation of a sprite. I have a working sprite class called AnimationSprite that loops through an array of images when it updates. The problem is that when my soon-to-be game is running at its frame rate (approx. 32) the "Animation Sprites" are looping through their animations too fast. I couldn't really think of a way to set a delay on their animations. I thought of using a Timer to run a TimerTask that increases the sprites' current frame at a sertain rate. Is this a good idea? Also, does GAGE run on Mac OS X? When I download it it just unzips an empty folder that doesn't contain any data.
    Anyways,
    Thanks for your time.

    static final ANIMATION_DELAY = 200;
    static final ANIMATION_FRAMES = 32;
    int counter = 0;
    //your animation loop
    g.drawImage(animFrame[(counter*ANIMATION_FRAMES)/ANIMATION_DELAY],x,y,null);
    if(++counter==ANIMATION_DELAY) counter=0;

  • Smooth object/sprite animation.

    Trying to make a smooth scroller in Flex and found the
    callLater method that looks good for updating position of sprites,
    my question is if anyone know how often this method is called?,
    need to refresh objects position quite frequently and is the usage
    of callLater the right way of doing this kind of sprite moving in
    flex, or is there better ways?
    Any ideas?

    > I've created some basic animations in flash at 24fps and
    published them.
    > When
    > viewing the .swf file the animation is smooth. But once
    I import them into
    > my
    > captivate project (set to 24fps) and view the published
    presentation some
    > of
    > the animations appear jery and not fluid at all.
    are you testing in Preview mode, or are you testing a
    published file? Just
    wondering ... if you are previewing you **might** get better
    performance
    once published.
    Steve
    Adobe Community Expert: eLearning, Mobile and Devices
    My blog -
    http://stevehoward.blogspot.com/

  • How to use Sprites in animation.

    Umm hi I would like some help on how to use sprites (8 or 16
    bit characters from games) to make an animation could any one
    provide me a link to any sprites animation or a link on how to do
    it. It will help much.
    Mr.Idiot

    if you have Flash, this is one of the main things that it
    does. open up your help file documentation, and start reading at
    the beginning, it will tell you all you need to know and introduce
    you to the basic concepts of the program.

  • Animating Sprites the slow poke approach...

    Hi there, I've got a small application which features small creatures controlled by some fearsome AI dashing around a randomly generated environment trying to kill each other. (it's somewhat more complex than that, but you get the gist). Rather than do the sensible thing and look for examples of Sprite animation, I just got stuck in, thinking, what the hell, I'll give it a shot. This is what I came up with....
    AnimationCanvas class extends JComponent, this is where all the animation stuff is drawn.
    SpriteManager class, contains a vector of all the sprites and is responsible for updates
    abstract Sprite class, provides an extensible template for sprites, I've got things like TreeSprite and RockSprite. Some of the sprites are composite sprites, comprising of several images which are overlapped slightly, an example of this is my AgentSprite it requires a total of 52 images, I load these using a MediaTracker when the object is instanciated before the app is displayed. They are all small images, less than 1k. The animation is done through the use of a Swing Timer which repaints the scene after a delay of 1000/24 ms, which I assume gives me 24fps ( is there a way of checking the fps? ) the AI portion of the app. updates the position of the sprites via the SpriteManager and also tells the Sprite what images to use. This works sweet on Win XP with my 2Ghz machine, but the target was to have it run on anything that runs Java 1.4 +. Running it under Linux on a PIII 500 for example is like watching paint dry. Great! Soooo I can only assume it is my inept implementation that is causing the problem, I have had a little look around and have seen a few people just using a single image with many sprites on it, using a PixelGrabber to get the desired bits, is this a more efficient method? Or does pre-loading the images with a MediaTracker do a better job? Or should a time my animation a different way? I would appreciate it if you could give me a tip or two.... I'm happy to post code snippets, but there's a fair ammount, specific bits might be easier... or if some of you are particularly adventurous i can put the source code up on the net for you to d/l and have a little look at :-)
    Cheers,
    Tom

    My source code, images and pre compiled classes are now available here...
    http://www.macs.hw.ac.uk/~ceetfc/ait/ait.zip

  • Looking for a more suitable animation tool

    I've been creating animations from sprites in After Effects, with mixed results.  The input is a number of pixel art sprites (exported from elsewhere), and the output is a video, characters running around and interacting.  I have AFX doing quite a lot, but it's very awkward and I'm pretty sure it's the wrong tool for the job.  Can anyone either suggest better approaches, or more suitable software?  I'll describe what I'm doing now:
    - Many sprites are bodies or heads to combine, eg. a smiling or angry faces and walking or standing bodies.  I set the head position for each body sprite, so any head fits in the right place on any body (trivial rigging), then apply it with a script, so I can change the body and the head moves to the right place automatically.
    - Some sprites have multiple layers.  For example, while heads are normally on top of bodies, a body may have an arm raised, which needs to be above the head instead of below it.  I can create the extra layer for the body separately, and it works for any head.
    - I can set the draw order per-layer.  Usually, one character and all of its parts is drawn on top of another--body1, head1, body2, head2.  But, if two characters collide, handshake, or interact in other complex ways, I may want to draw both bodies, and then both heads, even though the heads and bodies are still anchored normally.  Some sprites may have multiple layers, eg. body, head, hands, legs.  (Z position hack...)
    - Individual layers can be adjusted separately, eg. to adjust the default head position downwards to give a nod.
    - Some sprites are hue shifted (hair color, clothing color) or have more complex adjustments applied, so I can reuse more sprites.
    (I'm only describing what I'm doing and not how.  I wrote more detail about what I'm actually doing in AFX and the specific issues I'm having, but it was too long and people can probably already guess the practical issues of using AFX like this.  I'll post more info if anybody asks.)
    The result is functional, but a real hassle to actually work with.  AFX is a compositing and effects tool and it's not really designed for animations, and only its scripting support has let me abuse it this much.  I don't know of a better tool, though--searches for animation tools mostly come up with things like Spine (authoring individual models for importing into games), and nothing suitable for creating complex video animations from sprite sets.
    There are probably many tools to do small pieces of this (sprite animation sequences, effects, scene animation, camera), but I'd really like to not split into a multi-tool workflow, since I want to experiment freely with a scene, not lay out an entire scene and then create it start to finish.  Does anyone have any suggestions (or better places to ask)?

    There are many other DTP applications:
    http://www.freeforum101.com/iworktipsntrick/viewtopic.php?t=137&mforum=iworktips ntrick
    You have to be more specific about what you are looking for.
    Peter

  • Exporting PSD for Sprite-Sheets

    Hi, I have several sprites animated and saved in PSD form, how do I now convert them into Flash Professional so I can turn them into a sprite sheet from there?
    I have tried several ways but importing the PSD file doesn't load the layers up, it only loads the top one.

    Yes that should be possible using the above script. It generates a png sprite containing images on all the layers and a metadata file (.eas) for importing it into Edge Animate.
    If it doesn't work, can you share one of your psd files so that I can try out with it.

  • Which is best?

    I have a couple of questions regarding sprite animation in Java, I know a lot of you might say "we've seen this all before" but most of the answers I've found relate to specific Java game API's, which I don't want to use, I'd like to have a shot at doing it myself, so that I actually learn! So! Which is the best way of doing Sprite animation with the Java2D API:
    1) Use a single image (sprite sheet) and have a PixelGrabber "grab" the bits you need as and when you need them.
    2) Use lots of individual images to make up the frames of animation, cycling through an array of Images. (this is what my app. uses)
    And how is it best to time the animation:
    1) Use some kind of thread seperate from the main one, use Interrupts to determine when updates are required.
    2) Use a javax.swing.Timer that calls repaint 24 times a second and have the game logic run on a seperate timer. (this is what my app. uses)
    The reason I ask, is that I have implemented a simple extensible animation system, but it runs very slow on anything under about 800Mhz, any ideas? For those interested, my full source code is available here:
    http://www.macs.hw.ac.uk/~ceetfc/ait/ait.zip
    Hope someone can shed some light on what I'm doing wrong.
    Cheers,
    Tom

    You can have the animations and game logic on the very same thread (and should in my opinion). Just call the animations "update" everytime you loop through your game logic. If you don't want to perform the animation every loop (which I am guessing you don't), then pass the time that has passed since the last update call, and once enough time has gone by, then do update. Something to the extent of this in your animation code....
    public void update(long timePast) {
       timeSinceUpdate += timePast
       if (timeSinceUpdate  >= UPDATE_TIME) {
                timeSinceUpdate = timeSinceUpdate - UPDATE_TIME;
                 ........[insert your stuff here]........

  • Frustration with lack of support for Flash Player on IPad. When is Apple going to support Flash?

    When is Apple going to support Flash Player on IPad? 
    The majority of sites that have multimedia content rely on Flash. Safari users are missing out on tons and tons of content that depends on Flash.  I have and love my IPad 2. I should be able to use this awesome thing to get at anything I need to on the Internet. Yet when I need to access Flash sites, I am forced back to my windows PC.
    Please Apple Make it happen! I'm tired of being ragged by android users on this. You need to fix it.

    xx66stangxx wrote:
    Flash is a dieing technology.
    Really it's not seeming that way.
    In fact, since the iPad release, and Steve Jobs famously declairing the death of Flash, Flash useage has increased.
    Check it out 95.75% of all internet connected devices have the Flash Player.
    http://www.statowl.com/flash.php
    (the mac only has 12% share, it must be totally doomed then)
    IOS Apps are now made using Adobe Flash
    http://thenextweb.com/apple/2011/09/09/the-best-selling-ipad-app-on-the-app-stor e-was-created-with-adobe-flash/
    And so are Android, Blackberry etc.
    And HTML5 was supposed to be Apple's answer to all the missing content, yet here, 3 years later, HTML5 is no where to be seen, and lacks support/performance to compete with Flash.
    http://getmoai.com/images/banners/mobilegaming-html5-vs-alternatives-011112-moai .jpg
    Just look at how when you step outside the reality distortion field, things look much different. Look at HTML5 performance compared to Flash.... wasn't HTML5 supposed to outperform and save us from dead batteries? Well even 3 years after Steve Jobs claims it's still using 5x more resources than Flash.
    This demo shows 16,250 sprites animating at 60fps using the Flash player, something HTML5 can't even do with less than 100 sprites.
    http://www.bytearray.org/?p=4074
    HTML5 is a joke, Flash is real, and is providing real content to real people right now. If you as an Apple owner believe the ownership of an IOS device is worth this loss, then more power to you.

Maybe you are looking for

  • GarageBand v3 does not show up in Automator

    Greetings, I have been trying to create some sort of automation for my Church. We are recording teachings in GBv3. I would like to be able to do the following to make the process as simple as possible through two workflows. First workflow: 1. Open a

  • Disable all the previous dates in a calendar form

    hi guys, I am having a calendar form in which it displays all the previous,current,future dates and months.when i click on the particular button on the calendar it dispalys the date, month, and year.its working fine.But what i need is, i want to disa

  • How do you get bookmarks selected to appear in the full screen rather than the small window to the left

    When I click on a bookmarked site, some of them show up on the large screen to the right, but mostonly show up in the much smaller window to the left and are therefor useless. this is even when I've opened a new tab. I never had this problem before,

  • Could not turn on auto-commit in an active global transaction

    Why and when does toplink throw this exception 09/09/28 17:50:58 Caused by: java.sql.SQLException: could not turn on auto-commit in an active global transaction 09/09/28 17:50:58 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.jav

  • ESS - Family Members Detail screen

    Hello, I am on EP 7,NW04s, ERP 05 and tring to modify the Family Members Detail screen .I have already hidden some of the fields and moved some up and down but the Previous and the Review button and too far down because of the space created by hiding