Package pilas :: Package actores :: Module mano
[hide private]
[frames] | no frames]

Source Code for Module pilas.actores.mano

 1  # -*- encoding: utf-8 -*- 
 2  # Pilas engine - A video game framework. 
 3  # 
 4  # Copyright 2010 - Hugo Ruscitti 
 5  # License: LGPLv3 (see http://www.gnu.org/licenses/lgpl.html) 
 6  # 
 7  # Website - http://www.pilas-engine.com.ar 
 8   
 9  from pilas.actores import Actor 
10  import pilas 
11   
12 -class CursorMano(Actor):
13 """ 14 Representa un cusor del raton en forma de mano. 15 Cuando se pulsa el boton del ratón la mano cambia a un puño cerrado. 16 17 .. image:: images/actores/mano.png 18 19 """ 20
21 - def __init__(self, x=0, y=0):
22 """ 23 Constructor del cursor de la mano. 24 25 :param x: posicion horizontal del cursor. 26 :type x: int 27 :param y: posicion vertical del cursor. 28 :type y: int 29 30 """ 31 self._cargar_imagenes() 32 Actor.__init__(self, self.imagen_normal) 33 self.x = x 34 self.y = y 35 36 self.aprender(pilas.habilidades.SeguirAlMouse) 37 pilas.mundo.motor.ocultar_puntero_del_mouse() 38 self.z = -200 39 self.pulsado = False 40 41 self.centro = ("izquierda", "arriba") 42 43 self.escena.mueve_mouse.conectar(self.cuando_mueve_el_mouse) 44 self.escena.click_de_mouse.conectar(self.cuando_pulsa_el_mouse) 45 self.escena.termina_click.conectar(self.cuando_suelta_el_mouse)
46
47 - def _cargar_imagenes(self):
48 self.imagen_normal = pilas.imagenes.cargar("cursores/normal.png") 49 self.imagen_arrastrando = pilas.imagenes.cargar("cursores/arrastrando.png")
50
51 - def cuando_pulsa_el_mouse(self, evento):
52 self.pulsado = True
53
54 - def cuando_mueve_el_mouse(self, evento):
55 if self.pulsado: 56 self.imagen = self.imagen_arrastrando
57
58 - def cuando_suelta_el_mouse(self, evento):
59 if self.pulsado: 60 self.imagen = self.imagen_normal 61 self.pulsado = False
62