• I Still can’t get this scene to fade in? It fades out properly but will not faded in.

    class GameOver(Scene): def setup(self): self.game_over = SpriteNode( 'GameOver.PNG', position=(self.size.w/2, self.size.h/2), scale=1.10, parent=self) self.new_game = SpriteNode( 'StartNewGame.PNG', position=(self.size.w/2, self.size.h/2 * 0.33), scale=0.30, parent=self) self.game_over.alpha=0.5 self.new_game.alpha=0.5 self.game_over.run_action(A.fade_to(1, 2)) self.new_game.run_action(A.fade_to(1, 2)) def dismiss_scene(self): self.dismiss_modal_scene() def touch_began(self, touch): if touch.location in self.new_game.frame: self.main.bankroll_amount = 10_000 self.main.bankroll_amount_label.text = f'{self.main.currency_type}{self.main.bankroll_amount:,}' self.main.red_x.run_action(A.fade_to(0, 0.5)) self.main.main_node.run_action(A.fade_to(1, 1)) self.main.card_pos_1.run_action(A.fade_to(1, 1)) self.main.card_pos_2.run_action(A.fade_to(1, 1)) self.main.card_pos_3.run_action(A.fade_to(1, 1)) self.main.second_pos.run_action(A.fade_to(1, 1)) self.main.main_node.run_action(A.fade_to(1, 1.5)) self.game_over.run_action( A.sequence( A.fade_to(0, 2), A.wait(2), A.call(self.dismiss_scene))) self.new_game.run_action( A.sequence( A.fade_to(0, 2), A.wait(2), A.call(self.dismiss_scene
  • Thanks guys, I will study about shader and effect more Thanks!

  • @JonB I suppose you're right. I forget always that an action is only an animation due to change only one attribute of the node...Ha la la, my memory....👴🏻+👳🏼‍♂️

  • Thank you for suggesting Action.call. This is exactly what I needed. I had overlooked this in the documentation.

    In the end, I created a sub class of the SpriteNode and modified the run_action method to add an action.call at the beginning and end of the action sequence. So every card that gets animated adds it’s name to stack of actions that are currently animating.

  • Clearly I need to explore the API modules more :)

  • Ok thanks. Will give it a try

  • @omz thank you very much!!! Gonna try it

  • @ccc so sorry didn't see your whole response, That got it to work thank you very much!!!

  • @JonB , ok this is another refinement. To make it more generic, as well as receiving events can also raise our own events via the same mechanism. It's sort of ok, but I know it lacks some finesse.
    I know it's not great, but I feel it's getting there...
    If anyone has some ideas about how to improve this idea, love to hear about it.

    ''' Pythonista Forum - @Phuket2 ''' import ui def raise_event(sender, event_handler = None, **kwargs): sv=sender.superview if not event_handler: if not hasattr(sender, 'event_handler'): return else: event_handler = sender.event_handler handler = event_handler # walk up view chain to find callable action_name while sv: a=getattr(sv, handler, None) if callable(a): stop = a(sender, **kwargs) if stop: return sv=sv.superview return class BClass(ui.View): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.make_view() def make_view(self): btn = ui.Button(frame = (20, 20, 100, 32 )) btn.title = 'Next' btn.action = raise_event btn.event_handler = 'do_next' btn.border_width = .5 self.add_subview(btn) btn = ui.Button(frame = (20, 80, 100, 32 )) btn.title = 'Prev' btn.action = raise_event btn.event_handler = 'do_prev' btn.border_width = .5 self.add_subview(btn) # do_next is also defined in the parent class def do_next(self, sender = None): print('BClass:do_next') #return True def change_btn_name(self, sender, **kwargs): sender.title = kwargs.get('title', '') class MyClass(ui.View): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.view_b = BClass(frame = self.bounds) self.add_subview(self.view_b) def do_next(self, sender = None): print('MyClass:do_next') def do_prev(self, sender = None): print('MyClass:do_prev') raise_event(sender,'change_btn_name', title = 'WOW') if __name__ == '__main__': w, h = 320, 320 f = (0, 0, w, h) mc = MyClass(frame=f, bg_color='white') mc.present('sheet', animated=False)
  • Thanks a lot both. All the different solutions are working.

  • I hadn't realised the A.call() thing existed - loads of possibilities for animations!

  • Thanks so much. It works perfectly.

  • @JonB Thanks for the update.

    It seems to me that an extra parameter is needed for function add_action to actually allow user specified arguments like the follows:

    def add_action(scriptName,iconName='python',iconColor='',title='', arguments=None):

    I tested and it worked with 2.0.

  • I just found that this x-callback problem was already reported in this forum 9 month ago.

    @omz Can you please have a look into that?

Internal error.

Oops! Looks like something went wrong!