×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    7

    I'm trying to move my sprites

    I'm making a game and I try to move sprites but it doesn't work at all. I did the following:

    Sprite Cursor;
    (...)
    Cursor = new Sprite(Image.createImage("/Cursor.PNG"));
    (...)
    Cursor.setPosition(One.getX()+5,One.getY()+5);
    Cursor.paint(gc);
    (...)
    Cursor.setPosition(Two.getX()+5,Two.getY()+5);

    It doesn't crash but it doesn't change anything

  2. #2
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: I'm trying to move my sprites

    hi,

    make sure your graphics object is not null (you could have nullPointerException not trapped for some reason),
    make sure that sprite is drawn within graphics content clip rectangle,
    make sure your sprite is visible - if not visilbe it wont be drawn

    try following that tutorial:
    http://today.java.net/pub/a/today/20...e3.html?page=1
    (which uses Sprite.paint(g) in source code),

    off: do not use uppercase for object instances:
    http://java.sun.com/docs/codeconv/ht....doc8.html#367

    regards,
    Peter

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    7

    Re: I'm trying to move my sprites

    In fact, my graphic object IS null. But I don't understand why because when I use it with something else than sprites, it is not null and it works. What should I do?

  4. #4
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,697

    Re: I'm trying to move my sprites

    hi,

    divide at impera,
    divide your existing code into smaller parts to digg why you are working with null-ified object,
    usually it means that they are not initialized at all (having default value then),
    regards,
    Peter

Similar Threads

  1. Move focus from tab to list in containers
    By msalamah82 in forum Symbian User Interface
    Replies: 3
    Last Post: 2006-06-15, 04:19
  2. How can I move files from Messaging->Inbox on Series 60?
    By Donz in forum General Development Questions
    Replies: 2
    Last Post: 2004-11-17, 15:00
  3. Drawing sprites
    By tjankovic in forum Mobile Java Media (Graphics & Sounds)
    Replies: 4
    Last Post: 2003-12-18, 16:21
  4. Sprites
    By mshita in forum Mobile Java General
    Replies: 3
    Last Post: 2003-10-16, 11:50
  5. Sprites management remarks
    By atomictag in forum Mobile Java General
    Replies: 0
    Last Post: 1970-01-01, 02:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×