PDA

View Full Version : The sprite delay patch needs patched



rombust
10-16-2009, 07:42 PM
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 ---


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_attribu te(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_attribu te(cl_text("delay"), cl_text("20")));
}



Should be:



delay_ms = CL_StringHelp::text_to_int(cur_element.get_attribu te(cl_text("speed"), cl_text("50")));


Finally,


if (cur_element.has_attribute(cl_text("speed")))
{
sptr->delay_ms = CL_StringHelp::text_to_int(cur_element.get_attribu te(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_attribu te(cl_text("delay"), cl_text("20")));
}

Should be:



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

rombust
10-19-2009, 07:40 AM
Done

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