Step 5a. Activating modes based on shots
How do I add modes to play based on other shots and not just ball/game start. (a/k/a when to use AdvancedMode.Manual).
- Make sure the mode_type is AdvancedMode.Manual as shown below:
self.my_mode = MyCustomMode(game=self, priority=10,mode_type=AdvancedMode.Manual)
- Be sure to remember the name of the variable/reference that holds the mode as defined in T2Game.py.
In the example above, this is self.my_mode so the Game instance has a field called my_mode; we can refer to it in Mode code via: self.game.my_mode
- In Mode code, you can refer to the list of currently active modes (which lives in the game) as: self.game.modes
So, to activate/start your new mode (MyCustomMode) based on a specific switch or event in a different mode, in that switch/event handler you would add:
self.game.modes.add(self.game.my_mode)
- To conclude that mode from: 3a) a different mode:
self.game.modes.remove(self.game.my_mode)
3b) Within MyCustomMode itself:
self.game.modes.remove(self)