Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Fading alpha
-
I have this game over scene that is presented by the main scene. When the player runs out of money I can get the main scene to fade out and the game over scene to present but it does not fade from 0 to the maximum alpha. I also have an issue on the main screen where only some things are fading. I have a main node and then a card node. Most everything fades in as the game starts but the cards are still on the table. When the game is over I would like everything including the cards to fade away on the table. I should be able to figure this out but I must be missing something.
Here is the code for the GameOver seen that I’m having trouble fading the alpha.
The later is The section of code that fades most of the stuff but not the cards on the main scene.
class GameOver(Scene): def setup(self): #self.main.wooden_border() self.go_node = Node(parent=self) self.go_node.alpha=0 self.bg_color = SpriteNode( color='#477148', position=(self.size.w/2, self.size.h/2), size=(self.size.w, self.size.h)) self.game_over = SpriteNode( 'GameOver.PNG', position=(self.size.w/2, self.size.h/2), parent=self.go_node) self.new_game = SpriteNode( 'StartNewGame.PNG', position=(self.size.w/2, self.size.h/2 * 0.33), scale=0.25, parent=self.go_node) self.go_node.run_action(A.fade_to(1, 4))
Main screen code
if self.bankroll_amount == 0 and self.stake_amount == 0: self.card_node.run_action(A.fade_to(0, 1)) self.main_node.run_action(A.fade_to(0, 1)) go = GameOver() go.main = self self.present_modal_scene(go)
-
@resserone13 don't do the action in the setup because entire setup is created before presentation, then fading is already ended (not sure my explanation is correct 🙄)
class GameOver(Scene): def setup(self): | | V ui.delay(self.xxx,1) def xxx(self): self.go_node.run_action(A.fade_to(1, 4))
-
@cvp What I’m wondering then is how long set up takes. I am guessing fractions of a second. The fade should last 4 seconds. Also what if I put an action.wait(). Then the fade action. I don’t think that would work either. I’m also considering that the main scene is set up the same way and I have it fading in properly. When the game starts everything fades in. I do have some trouble getting the cards to fade out when I go to the game over screen from the main screen. Again it’s set up just like the original first fade in when the game starts but doesn’t work. Also when you come back from the game over scene I have everything fading in properly. When I remove the alpha equals zero attribute this on the game over scene the game over sprites show up. But do not fade in. So for some reason the action is never occurring I believe. I’m trying to simulate fading transitions between scenes.
-
@resserone13 said:
main scene is set up the same way and I have it fading in properly.
Thus my explanation is not correct, sorry 😢
-
@cvp no worries.
I was thinking the same. I always get off of work and I’m like hopefully everybody is up and ready for my question. Lol it’s almost 1 am over here. It’s getting towards bedtime. hahah
-
I have the scenes fading out nicely with this here.
def dismiss_scene(self): self.dismiss_modal_scene() def touch_began(self, touch): if touch.location in self.close_rules.frame: self.rules_node.run_action( A.sequence( A.fade_to(0, 2), A.wait(1), A.call(self.dismiss_scene)))
Just having trouble fading in the game over scene.
-
@resserone13 sorry but I can't help you 😢
-
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