void CSprite::StartFrames() { if (!m_addingFrames) { m_spriteDesc = CL_SpriteDescription(); m_addingFrames = true; } }
/** Displays the image view with its current image/ texts. */ void CAImageSelector::display( bool active ) { CAImageView::display( active ); CL_Rect crAll( 0,0, CA_APP->width, CA_APP->height ); CL_Rect crImage( left,top, right, bottom ); CA_APP->graphicContext->set_cliprect( crImage ); // Animate: // float diff = (float)newImage - currentImage; float numImages2 = (float)numImages/2.0; bool forward = false; // Move forward or back? // if( (diff < numImages2 && diff > 0.0) || (diff < -numImages2) ) { forward = true; } // Correct frame difference: // if( diff < -numImages2 ) diff += numImages; if( diff > numImages2 ) diff -= numImages; if( forward ) currentImage += fabs( diff ) / 6.0; else currentImage -= fabs( diff ) / 6.0; if( currentImage< 0.0 ) currentImage+=(float)numImages; if( currentImage>(float)numImages ) currentImage-=(float)numImages; int image1 = (int)floor( currentImage ); int image2 = (int)ceil( currentImage ); if( image2>=numImages ) image2=0; float rest = currentImage-image1; int center; CL_SpriteDescription im1_desc = CL_SpriteDescription(); CL_SpriteDescription im2_desc = CL_SpriteDescription(); im1_desc.add_frame(image[image1].image); im2_desc.add_frame(image[image2].image); CL_Sprite im1(*CA_APP->graphicContext,im1_desc); CL_Sprite im2(*CA_APP->graphicContext,im2_desc); if( direction==Horizontal ) { center = (left+right)/2; int image1Pos = (int)(center - rest*width - image[image1].image.get_width()/2); im1.draw ( *CA_APP->graphicContext,image1Pos, top+barHeight); im2.draw ( *CA_APP->graphicContext,image1Pos + width, top+barHeight); } else { center = (top+bottom)/2; int image1Pos = (int)(center - rest*height - image[image1].image.get_height()/2); im1.draw ( *CA_APP->graphicContext,(left+right-image[image1].image.get_width())/2, image1Pos); im2.draw ( *CA_APP->graphicContext,(left+right-image[image1].image.get_width())/2, image1Pos + height); } displayArrows( active ); CA_APP->graphicContext->set_cliprect( crAll ); }
CSprite::CSprite() { m_sprite = CL_Sprite(g_Display->Graphics().Object(), CL_SpriteDescription()); m_addingFrames = false; }