comparison demos/rpg/scripts/objects/baseobject.py @ 576:a21915a97237

Added some debug capability when building with mingw on windows. This should work for you if you have debug versions of python available. Added the show and hide functions to the baseobject in the RPG demo.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Mon, 05 Jul 2010 19:36:41 +0000
parents f85762e634c5
children
comparison
equal deleted inserted replaced
575:872a7a94563e 576:a21915a97237
46 def __init__(self, gamecontroller, obj): 46 def __init__(self, gamecontroller, obj):
47 fife.InstanceActionListener.__init__(self) 47 fife.InstanceActionListener.__init__(self)
48 self._gamecontroller = gamecontroller 48 self._gamecontroller = gamecontroller
49 self._object = obj 49 self._object = obj
50 50
51 self._attached = False
52
51 def detachActionListener(self): 53 def detachActionListener(self):
52 self._object.instance.removeActionListener(self) 54 if self._attached:
55 self._object.instance.removeActionListener(self)
56 self._attached = False
53 57
54 def attachActionListener(self): 58 def attachActionListener(self):
55 self._object.instance.addActionListener(self) 59 if not self._attached:
60 self._object.instance.addActionListener(self)
61 self._attached = True
56 62
57 def onInstanceActionFinished(self, instance, action): 63 def onInstanceActionFinished(self, instance, action):
58 pass 64 pass
59 65
60 66
95 else: 101 else:
96 self._findFIFEInstance(self._layer) 102 self._findFIFEInstance(self._layer)
97 103
98 self._activated = True 104 self._activated = True
99 105
106 def hide(self):
107 """
108 Marks the FIFE instance as not visible
109 """
110 if self._instance:
111 self._instance.get2dGfxVisual().setVisible(False)
112
113 def show(self):
114 """
115 Marks the FIFE instance as not visible
116 """
117 if self._instance:
118 self._instance.get2dGfxVisual().setVisible(True)
119
100 def destroy(self): 120 def destroy(self):
101 """ 121 """
102 Deletes the FIFE instance from the actor layer on the map. 122 Deletes the FIFE instance from the actor layer on the map.
103 """ 123 """
104
105 #This doesnt work
106 #self._instance.get2dGfxVisual().setVisible(False)
107
108 #remove from the scene instead
109 if self._actionlistener: 124 if self._actionlistener:
110 self._actionlistener.detachActionListener() 125 self._actionlistener.detachActionListener()
111 self._actionlistener = None
112 126
113 if self._instance : 127 if self._instance :
114 self._layer.deleteInstance(self._instance) 128 self._layer.deleteInstance(self._instance)
115 self._instance = None 129 self._instance = None
116 130
117 self._activated = False 131 self._activated = False
118 132
119 def spawn(self, x, y): 133 def spawn(self, x, y):
120 #This doesnt work 134 """
121 #self._instance.get2dGfxVisual().setVisible(True) 135 Creates a new FIFE instance and spawns it in the specified x y location
122 136 """
123 if self._instance: 137 if self._instance:
124 self._setMapPostion(x,y) 138 self._setMapPostion(x,y)
139 self.show()
125 else: 140 else:
126 self._position.x = x 141 self._position.x = x
127 self._position.y = y 142 self._position.y = y
128 self._createFIFEInstance(self, self._layer) 143 self._createFIFEInstance(self, self._layer)
144
145 if self._actionlistener and self._instance:
146 self._actionlistener.attachActionListener()
129 147
130 self._activated = True 148 self._activated = True
131 149
132 def setMapPosition(self, x, y): 150 def setMapPosition(self, x, y):
133 curloc = self.location 151 curloc = self.location
219 return self._activated 237 return self._activated
220 238
221 def _setActivated(self, activate): 239 def _setActivated(self, activate):
222 self._activated = activate 240 self._activated = activate
223 241
224
225 location = property(_getLocation, _setLocation) 242 location = property(_getLocation, _setLocation)
226 instance = property(_getInstance) 243 instance = property(_getInstance)
227 type = property(_getType) 244 type = property(_getType)
228 id = property(_getId) 245 id = property(_getId)
229 modelname = property(_getModelName) 246 modelname = property(_getModelName)
230 position = property(_getPosition, _setPosition) 247 position = property(_getPosition, _setPosition)
231 activated = property(_getActivated, _setActivated) 248 active = property(_getActivated, _setActivated)