|
@@ -126,6 +126,8 @@ class Callback(object):
|
126
|
126
|
func: typing.Callable[[], None],
|
127
|
127
|
duration: float,
|
128
|
128
|
delay: float=None,
|
|
129
|
+ end_callback: typing.Callable[[], None]=None,
|
|
130
|
+ start_callback: typing.Callable[[], None]=None,
|
129
|
131
|
) -> None:
|
130
|
132
|
self.func = func
|
131
|
133
|
self.duration = duration
|
|
@@ -135,8 +137,13 @@ class Callback(object):
|
135
|
137
|
self.delay = delay
|
136
|
138
|
if delay is not None:
|
137
|
139
|
self.require_delay = True
|
|
140
|
+ self.end_callback = end_callback
|
|
141
|
+ self.start_callback = start_callback
|
138
|
142
|
|
139
|
143
|
def execute(self) -> None:
|
|
144
|
+ if self.started is None and self.start_callback:
|
|
145
|
+ self.start_callback()
|
|
146
|
+
|
140
|
147
|
if self.require_delay and not self.started:
|
141
|
148
|
self.started = time.time()
|
142
|
149
|
return
|
|
@@ -153,8 +160,15 @@ class Callback(object):
|
153
|
160
|
self.func()
|
154
|
161
|
elif not self.duration:
|
155
|
162
|
self.func()
|
|
163
|
+
|
|
164
|
+ if self.end_callback is not None:
|
|
165
|
+ self.end_callback()
|
|
166
|
+
|
156
|
167
|
raise FinishedCallback()
|
157
|
168
|
else:
|
|
169
|
+ if self.end_callback is not None:
|
|
170
|
+ self.end_callback()
|
|
171
|
+
|
158
|
172
|
raise FinishedCallback()
|
159
|
173
|
|
160
|
174
|
|
|
@@ -249,11 +263,20 @@ class EditLayer(cocos.layer.Layer):
|
249
|
263
|
self.selectable_actors = []
|
250
|
264
|
self.callbacks = [] # type: typing.List[Callback]
|
251
|
265
|
|
252
|
|
- def append_callback(self, callback: typing.Callable[[], None], duration: float, delay: float=None) -> None:
|
|
266
|
+ def append_callback(
|
|
267
|
+ self,
|
|
268
|
+ callback: typing.Callable[[], None],
|
|
269
|
+ duration: float,
|
|
270
|
+ delay: float=None,
|
|
271
|
+ start_callback: typing.Callable[[], None]=None,
|
|
272
|
+ end_callback: typing.Callable[[], None]=None,
|
|
273
|
+ ) -> None:
|
253
|
274
|
self.callbacks.append(Callback(
|
254
|
275
|
callback,
|
255
|
276
|
duration,
|
256
|
277
|
delay=delay,
|
|
278
|
+ start_callback=start_callback,
|
|
279
|
+ end_callback=end_callback,
|
257
|
280
|
))
|
258
|
281
|
|
259
|
282
|
def set_selectable(self, actor: Actor) -> None:
|