Results 1 to 5 of 5

Thread: Speed of Sprite

  1. #1

    Default Speed of Sprite

    I have a problem :
    I have a Sprite with 7 images (frames) .. but How change speed of progress through the frames?

    because I change tag speed in resource.xml but the result is not what I want ..

    Sorry for my english

  2. #2
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    Do you call sprite.update() once each frame?

  3. #3

    Default

    yes !!

    sprite.update(41,66);

    41,66=1000/24

  4. #4

    Default

    Someone can help me?

  5. #5
    ClanLib Developer
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    554

    Default

    CL_Sprite::update takes the time elapsed since last time you rendered it - not your desired frame rate. So if you always specify 41.66 ms, then that would be wrong unless you also only flip the display 24 times per second.

    You probably want something like this:

    int last_time = CL_System::get_time();
    while (!exit)
    {
    int cur_time = CL_System::get_time();
    int delta = cur_time - last_time;
    last_time = cur_time;
    display.clear();
    sprite.update(delta);
    sprite.draw();
    display.flip();
    CL_System::keep_alive();
    }

Similar Threads

  1. Creation of CollisionOutline by using a Resource/Sprite
    By Nipsky in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 09-22-2007, 10:08 PM
  2. sprite constructor
    By Krux in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 09-21-2007, 06:52 AM
  3. Sprite patch for 0.8
    By Trigve in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 07-19-2007, 12:41 AM
  4. Custom resource combined with sprite
    By tompawarrior in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 07-17-2007, 05:30 PM
  5. Green border around rotated sprite on ATI cards - Solved!
    By pTymN in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 11-06-2006, 08:44 PM

Bookmarks

Bookmarks

Posting Permissions

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