Package Things :: Module Thinglets :: Class LoopThing
[frames] | no frames]

Class LoopThing

       object --+        
                |        
timeline.Timeline --+    
                    |    
   ThingObjects.Thing --+
                        |
                       LoopThing

A LoopThing is a way to control the frames of a Loop that you get from your BagOfStuff. Normally you simply draw() an item in the bag and you can't set the keys at which its sub-frames appear.

Use a LoopThing to set keys (etc.) on a loop. Each frame of your loop will appear once per keyframe, marching forward in time.

Now you can tween a walk-cycle (say) from one keyframe to the next.

Notes

  1. You can have more keys than frames in a loop. The loop will wrap per extra key it finds.
  2. Use addLoop() to add your BagOfStuff loop, not add(). You can still add() things to this Thing, but only addLoop() will control the loop. You can only use addLoop() once.

Example

Typical use:

class TweenLoopWalk(LoopThing):
  def __init__(self):
    LoopThing.__init__(self,"DuckWalking")
    ## Let's assume our walkloop has three frames. Here we choose to tween it between
    ## four keyframes, so that we get a smooth cycle.
    self.keys  ( "#---#---#---#", Props(),Props(x=10),Props(x=10,y=10),Props(x=20,y=-20))

    ## Now get a loop cycle from an SVG file:
    BOOP = BOS['rsvg:walkloop'] # Where BOS is an instance of a BagOfStuff.
    ## And add it to myself with the special method for this:
    self.addLoop(BOOP)

ends.

Draw

You don't have to have a draw() method, but if you do then be sure to call the draw() method of the LoopThing after you are done:

Example:

def draw(self,ctx,fr):
  someShape(ctx) # your own extra drawing
  # To continue the draw, call the parent's draw method.
  LoopThing.draw(self,ctx,fr)

ends.

Instance Methods
 
__init__(self, id='noid')
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
 
addLoop(self, BOSloop)
Adds a loop from a BagOfStuff to the LoopThing.
 
draw(self, ctx, frame)
See help(LoopThing) for more info.

Inherited from ThingObjects.Thing: __len__, changeLayer, changeProps, funcs, getProps, goPlay, goStop, jumps, keys, labels, loop, nextFrame, play, showData, stop, stops, toTop

Inherited from timeline.Timeline: add

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Instance Variables

Inherited from ThingObjects.Thing: currentFrame, frame, globalProps, lifespan

Inherited from timeline.Timeline: parentThing

Properties

Inherited from object: __class__

Method Details

__init__(self, id='noid')
(Constructor)

 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Parameters:
  • id - A string to identify this Thing. It's mainly for debug purposes, but handy within your own code too.
Overrides: object.__init__
(inherited documentation)