Sequence of Action with a LabelNode
BillBaroude last edited by ccc
I probably just don't get the right way to do (sorry, newcomer to Pythonista), but I can't figure out how to make it work.
I would like to play a serie of actions on LabelNodes for a game splash screen.
I move elements to the right place, sequentialy, using also "wait"
The problem I have is the last sequence, where only the fade out (fade_to (0,.1)) is working. I can't get the fade in (fade-to (1,.1) working...The goal will be to smooth blink 'Press To Start" using a "repeat" at the end.
Any idea ?
Here is my code :
# splash screen # done with scene Actions from scene import * import sound import random import math A = Action class Splash (Scene): def setup(self): self.background_color = '#efefef' med_font =('Futura', 30) self.title_buton =LabelNode('Press to Start', med_font, color ='black') self.title_buton.position = (self.size.w/2,-100) self.title_buton.z_position = -1 self.title_buton.alpha = 1 self.add_child(self.title_buton) def did_change_size(self): pass def update(self): self.title_buton.run_action(A.sequence(A.wait(.5),A.move_to(self.size.w/2,self.size.h/2-160,.1))) #the following seq never plays the "fade_to (1,0.1)" instruction :( self.title_buton.run_action(A.sequence(A.wait(2),A.fade_to(0,0.5,TIMING_LINEAR),A.wait(0.5),A.fade_to(1,0.5,TIMING_LINEAR))) if __name__ == '__main__': run(Splash(), PORTRAIT, show_fps=True)
omz last edited by
You generally shouldn't add actions in the
updatemethod. That will be called about 60 times per second, so your actions restart all the time. Simply add your actions in
setupinstead (that will be called once).
BillBaroude last edited by
Thanks ! That was really simple ...
My side I was wondering that the Action structure were independant of the loop and was done to complete anyway. My bad :)