pyzzle :: Hotspot :: Hotspot :: Class Hotspot
[hide private]
[frames] | no frames]

Class Hotspot

source code

          object --+    
                   |    
pygame.sprite.Sprite --+
                       |
                      Hotspot

Pygame Sprites representing parts of a slide that the user can click.

Instance Methods [hide private]
 
_save(self) source code
 
__init__(self, parent, link, id=None, rectRel=None, layer=0.0, cursor='', delay=.1, zip=False, soundfile=None, text=None, drag=None, _template=False, onClick=lambda self: Hotspot.transition(self), onHighlight=lambda self: None, onTransition=standard._noTransition)
Creates a new Hotspot.
source code
 
_getRect(self)
The portion of the screen the user may click to activate the Hotspot.
source code
 
_setRect(self, rect) source code
 
_getLink(self)
The Panel the user will transition to when the Hotspot is activated
source code
 
_setLink(self, slide) source code
 
_getEnabled(self) source code
 
_setEnabled(self, value) source code
 
draw(self, screen)
Draws the Hotspot's border, if the game is in design mode.
source code
 
highlight(self)
Called when the user hovers over the Hotspot.
source code
 
click(self, design=False)
Called when the user clicks the Hotspot.
source code
 
transition(self)
Commands the hotspot to transition the user to the link.
source code
 
design(self, drag=True) source code

Inherited from pygame.sprite.Sprite: __repr__, add, add_internal, alive, groups, kill, remove, remove_internal, update

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__

Static Methods [hide private]
 
_load(cells) source code
Class Variables [hide private]
  __metaclass__ = Table
  cursorDefault = 'fwd.png'
The value of the cursor attribute when no other is specified
  rect = property(_getRect, _setRect)
  link = property(_getLink, _setLink)
  enabled = property(_getEnabled, _setEnabled)
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, parent, link, id=None, rectRel=None, layer=0.0, cursor='', delay=.1, zip=False, soundfile=None, text=None, drag=None, _template=False, onClick=lambda self: Hotspot.transition(self), onHighlight=lambda self: None, onTransition=standard._noTransition)
(Constructor)

source code 

Creates a new Hotspot.

Parameters:
  • id - A unique identifier for the Hotspot. Used to refer to the Hotspot in scripts and the database
  • parent - Panel in which the Hotspot resides. Note: This will not add the slide to the panel. You still need to add it using Slide.enter() or one of the transition functions
  • link - Slide the Hotspot will transition to when clicked
  • rectRel (RelativeRect) - The relative coordinates representing the area that can be clicked. Coordinates are relative to the size of parent.
  • layer - The layer of the Hotspot. Larger numbers represent upper layers. When the player clicks on an area of the Slide where two Sprites overlap, the sprite with the topmost layer is the only one that's activated.
  • cursor - The name of the cursor file that is displayed when no hotspots are highlighted. The default is defined by Panel.cursorDefault. None displays no cursor.
  • delay - The time that should be taken to transition from parent to link when the Hotspot is clicked.
  • zip - Whether this is a zip hotspot (disabled unless zip mode is on and the link has been visited).
  • soundfile - The name of the sound file played when the user clicks the hotspot.
  • text - Text that is displayed under the cursor when the user highlights the Hotspot.
  • drag (RelativeRect) - The relative coordinates of the area the user must drag to activate the hotspot.
  • onClick - The function that is called when the Hotspot is clicked. If the drag parameter is specified, this function will not be called until the user has dragged the Hotspot to the correct location.
  • onHighlight - The function that is called when the Hotspot is clicked.
  • onTransition - The transition function used to transition from parent to link when the Hotspot is clicked.
Overrides: object.__init__

highlight(self)

source code 

Called when the user hovers over the Hotspot. Draws cursor and text to the screen, where present, and calls onHighlight

click(self, design=False)

source code 

Called when the user clicks the Hotspot. Plays soundfile and calls onClick. If drag is specified, the user must drag the cursor to the drag area in order to call onClick.

Parameters:
  • design - Used only for design mode

transition(self)

source code 

Commands the hotspot to transition the user to the link. onClick must explicitly call this to transition the user. This makes it very easy to script certain behavior, such as for locks.