Package Things :: Module ThingObjects :: Class HitThing
[frames] | no frames]

Class HitThing

       object --+        
                |        
timeline.Timeline --+    
                    |    
                Thing --+
                        |
                       HitThing
Known Subclasses:

Subclass this to have your object draw a hit area and detect hits. This gives your Thing the power to receive all kinds of mouse events.

This is a normal Thing, and can have other things added to it. See the help for Thing and Timeline.

Events

These events are fired. Catch them by defining a def with one of these names.

  1. onDrag(x,y)
  2. onDrop(dx,dy,x,y) : Use (dx,dy) to change props with. (x,y) are useful for hit testing.
  3. onDown(x,y)
  4. onRelease()/onClick()
  5. onEnter(x,y)
  6. onRollOver(x,y)
  7. onLeave(x,y)

Hit Area

Define a drawHitarea method where you then draw (using paths, not stroked or filled) the hit area.

The signature is: def drawHitarea(self,context,frame_number)

Use

Typical use:

 class Touchy(HitThing):
   def __init__(self,x, y): # this is up to you
     ## Init the class - very important.
     HitThing.__init__( self, id="button" )
     self.keys( "#", Props() )
   def onRollOver(self,x,y):
     print "You are in ",x,y
   def drawHitarea(self,ctx,fr):
     ctx.rectangle(0,0,50,50) # this rectangle will be the hit-area

.

Instance Methods
 
__init__(self, id='Hitter')
x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Inherited from 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 Thing: currentFrame, frame, globalProps, lifespan

Inherited from timeline.Timeline: parentThing

Properties

Inherited from object: __class__

Method Details

__init__(self, id='Hitter')
(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)