pyglet, i don't understand why this code isn't working
songbird
songbird at anthive.com
Fri Nov 2 17:33:58 EDT 2018
MRAB wrote:
> On 2018-11-02 19:58, songbird wrote:
>>
>> hello, :)
>>
>> my question is below, a bit of background first.
>> i'm very new to python and picking it up by working
>> on a project for fun.
>>
>> please don't critique my style or lack of
>> classes/objects in the code yet - i'm way too new. :)
>>
>>
>> my current project is at:
>>
>> https://salsa.debian.org/ant-guest/gfpoken-in-python/
>> https://salsa.debian.org/ant-guest/gfpoken-in-python/tree/next
>>
>> i'm using pyglet (most recent version) and gtk...
>> in Debian Linux testing.
>>
>> my question is that in on_animation_end in the my_sprite.py
>> class doesn't seem to work as i'd expect.
>>
>> i never reach: print ("Do we Ever get here?") statement.
>>
>> and i'm curious if i've just messed up something obvious
>> here or if my problem is elsewhere?
>>
> [snip]
> In __init__ you initialise self.animation_initial_turn_it_off to True.
>
> Nowhere in your code do you change it, so it remains True.
i wish it were that easy...
see my_sprite.py
...
def on_animation_end (self):
# we're already running when initialised so we
# have to shut it off until we restart it again
# but we only have to do this once as from then on
# each animation will check the global flag to see
# if it should run
# print ("AF AC ", self.animation_foo, self.animation_count)
self.animation_foo = False
self.animation_count += 1
if ((self.animation_initial_turn_it_off == True) and
(self.animation_running == True)):
print ("initial shut down animation AR True")
pyglet.clock.unschedule(self._animate)
self.animation_initial_turn_if_off = False
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
self.animation_running = False
pprint.pprint(MySprite.__mro__)
pprint.pprint(MySprite.on_animation_end)
elif ((self.animation_initial_turn_it_off == True) and
(self.animation_running == False)):
# we shouldn't get here, but just in case
# just turn it off again...
# print ("initial shut down animation AR False")
self.animation_initial_turn_if_off = False
...
songbird
More information about the Python-list
mailing list