================================================================
python/pysfml-animatedsprite-class-supplies-next-method-to-adjus
================================================================

.. raw:: html

   <table class="provenance-header" style="border: 0; border-collapse: collapse; margin: 0 0 16px 0; width: 100%;">

.. raw:: html

   <tr style="border: 0;">

.. raw:: html

   <td style="border: 0; vertical-align: top; padding: 0 24px 0 0;">

..

   | **Source:**
     https://foxhop.net/f3a7e91f-2f95-11f1-b18c-e86a64d24d78/python-pysfml-animatedsprite-class-supplies-next-method-to-adjus
   | **Snapshot:** 2026-10-16T05:50:45Z
   | **Generator:** Remarkbox ``d747782``

   *This is a thread snapshot. The living document lives at the source
   URI above — it may have been edited, extended, or replied-to since.*

.. raw:: html

   </td>

.. raw:: html

   <td style="border: 0; vertical-align: top; width: 200px; text-align: right;">

.. figure:: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMQAAADEAQAAAADo3bPGAAAB+0lEQVR42t1YwY0CQQyzaCD9d+kOQuwMHyQ+aPyAvRM6ltNaSRzbA/rDRfzoJwAKZLPnv0BUl27xgU/XN5+gq/Xgqh6EQWLRt+7jDMY8WxUJjaBvRXDm0VUwEMCK4ahj1KQ0H4RwWr8zEKHN/Pf9fRyR6+2K8M30NuOG0dOxIYRvXe8bt1uq4lBPM7tfj7hc4sP8NTzw2qIT8xGaa5l3LZhO1DMKoOWcn5lQe5umjffrKWmaNlVwu7WCTfBNKiBN5dkiJviGtuZ4S8u4iPSthUXudnJJHeCB1UANg14oXzA3rvfN64J9vK1IxSX02u2COS0ujBVF9I3WN9dg4vk1owdSNxPhuDgyvt22UcnbimlH6uFujdBKMaEyfqrwYcmRN7QbqN29jmOP09asDx33DuiOeGwdle6wnBaZmI/VU2B2BnkrKuHblgHh0QZOaUQlcCDjWYMgsHwIzMfaIzrI33Ci/X3dwfJNZLB7b6K7z2ucUwlN8c0KCZ/TqiodSHTE8ikrwWv2y+v6BJE9n9zPIZsONog4XSHh25uqzhkL3lQkcuImA2zitQmt+0Xym3dTeuNNiuiOg7tjiHxnRS7hC+vUPL4jQoR09JVCNyi6wmLmHGy7szuI04zw2mFgg1XbwekzamQ+a0B7ODkCEeKbv3nZ02PoXPJf34s9AZIKovH/Ym7tAAAAAElFTkSuQmCC
   :alt: Scan for living source

   Scan for living source

.. raw:: html

   </td>

.. raw:: html

   </tr>

.. raw:: html

   </table>

PySFML AnimatedSprite class supplies Next method to adjust frames
=================================================================

.. container::
   :name: cb1

   ::

      from PySFML import sf

      class AnimatedSprite( sf.Sprite ):
          def __init__( self, image, columns=1, rows=1, sequence=None, columnwidth=None, rowheight=None ):
              super( AnimatedSprite, self ).__init__( image )

              totalwidth, totalheight = self.GetSize() 

              if columnwidth: self.columnwidth = columnwidth 
              else: self.columnwidth = int( totalwidth / columns )

              if rowheight: self.rowheight = rowheight
              else: self.rowheight = int( totalheight / rows )

              if sequence:
                  self.sequence = sequence
              else:
                  self.sequence = [ number for number in range( 1, ( columns * rows ) + 1 ) ]

              # create a frames list of column and row tuples
              self.frames = [ (x,y) for y in range( 1, rows + 1 ) for x in range( 1, columns + 1 ) ]

              self.current = self.tick = self.complete = 0

              # set the first frame 
              self.Next( self.tick )

          def Next( self, tickrate = 12 ):
              """
              Pass an optional tickrate.
              If tick is greater or equal to tickrate:
              Move the Sub Rectangle or view to the Next position.
              Set complete to True when sequence finishes.
              """
              self.tick += 1

              if self.tick >= tickrate:

                  self.tick = 0
                  column, row = self.frames[ self.sequence[ self.current ] - 1  ]

                  subrect = sf.IntRect( 
                      self.columnwidth * ( column - 1 ), 
                      self.rowheight * ( row - 1 ), 
                      self.columnwidth * column,
                      self.rowheight * row
                  ) 

                  self.SetSubRect( subrect ) 

                  self.current += 1
                  if self.current >= len( self.sequence ):
                      self.complete = True
                      self.current = 0

Some example sprite timeline images
===================================

.. image:: /attachment/numbers.png

--------------

| **Source:**
  https://foxhop.net/f3a7e91f-2f95-11f1-b18c-e86a64d24d78/python-pysfml-animatedsprite-class-supplies-next-method-to-adjus
| **Snapshot:** 2026-10-16T05:50:45Z
| **Generator:** Remarkbox ``d747782``
