Results 1 to 2 of 2

Thread: The sprite delay patch needs patched

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default The sprite delay patch needs patched

    In SVN 3983, I changed CL_Sprite animation timing to use milliseconds (ints) instead of seconds (float).

    I made a mistake, in assuming the Resources "speed" parameter was in frames per second.

    ClanLib/Development/ClanLib-2.0/Documentation/Overview/sprites-resources.html -- This will need reverting to its original state.


    ClanLib/Development/ClanLib-2.0/Sources/Display/2D/sprite_impl.cpp ---
    Code:
    int delay_ms = 1000 / 50; // Default to 50fps (as per documention)
    if (cur_element.has_attribute(cl_text("speed"))) 
    {
      delay_ms = CL_StringHelp::text_to_int(cur_element.get_attribute(cl_text("speed"), cl_text("50")));
      if (delay_ms == 0)
      throw CL_Exception(cl_text("You cannot have 0fps for animation speed"));
      delay_ms = 1000 / delay_ms;
     }
    if (cur_element.has_attribute(cl_text("delay")))
    {
      delay_ms = CL_StringHelp::text_to_int(cur_element.get_attribute(cl_text("delay"), cl_text("20")));
    }
    Should be:

    Code:
    delay_ms = CL_StringHelp::text_to_int(cur_element.get_attribute(cl_text("speed"), cl_text("50")));
    Finally,

    Code:
    if (cur_element.has_attribute(cl_text("speed")))
    {
     sptr->delay_ms = CL_StringHelp::text_to_int(cur_element.get_attribute(cl_text("speed"), cl_text("50")));
     if (sptr->delay_ms == 0)
     throw CL_Exception(cl_text("You cannot have 0fps for frame speed"));
     sptr->delay_ms = 1000 / sptr->delay_ms;
    }
    if (cur_element.has_attribute(cl_text("delay"))) 
    {
     sptr->delay_ms = CL_StringHelp::text_to_int(cur_element.get_attribute(cl_text("delay"), cl_text("20")));
    }
    Should be:

    Code:
    if (cur_element.has_attribute(cl_text("speed")))
    {
     sptr->delay_ms = CL_StringHelp::text_to_int(cur_element.get_attribute(cl_text("speed"), cl_text("50")));
    }

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Done

    Note, the delay default is 60ms to maintain compatibility (This is what the original code was, the documentation said it was 50)

Similar Threads

  1. HSV Sprite Example
    By Judas in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 08-23-2009, 07:46 PM
  2. sprite question?
    By Mahdi in forum Official ClanLib SDK Forums
    Replies: 0
    Last Post: 09-07-2008, 12:18 PM
  3. Speed of Sprite
    By Nikitto46 in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 01-09-2008, 06:33 PM
  4. CL 0.8 Canvas patch, get-rid-of-warnings patch
    By Trigve in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 09-30-2007, 11:08 PM
  5. Sprite patch for 0.8
    By Trigve in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 07-19-2007, 12:41 AM

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
  •