Forum Archive

Add emoji behind text

sodoku

I don’t know if this is possible to do??? but can I add emojis to the label nodes position by typing the current text that is in the label into the pause menus TextField and pushing the button and the pawz.pyui only has one TextField and one button
The goal is to place an emoji behind both level 1 labels by only typing Level 1 into the TextField once

from scene import *

class Game (Scene):
        def setup(self):
            self.background_color = '#004f82'
            ground = Node(parent=self)
            x = 0
            while x <= self.size.w + 64:
                tile = SpriteNode('plf:Ground_PlanetHalf_mid', position=(x, 0))
                ground.add_child(tile)
                x += 64
            self.player = SpriteNode('plf:AlienGreen_front')
            self.player.anchor_point = (0.5, 0)
            self.player.position = (self.size.w/2, 32)
            self.add_child(self.player)

        self.player = SpriteNode()
        self.player.anchor_point = (0.5, 0)
        self.player.position = (self.size.w/4, 32)
        self.add_child(self.player)
        self.player.color = ('red')

        #Label 1
        self.card = LabelNode('Level 1',color=('#0016ff'))
        #self.card = LabelNode((text[0]),color=('#0016ff'))
        self.card.position = (300,760)
        self.add_child(self.card)
        self.card.size = (160,160)

        self.card2 = LabelNode('Level 2',color=('#0016ff'))
        self.card2.position = (300,660)
        self.add_child(self.card2)
        self.card2.size = (160,160)

        self.card3 = LabelNode('Level 1',color=('#0016ff'))
        self.card3.position = (300,560)
        self.add_child(self.card3)
        self.card3.size = (160,160)

        self.card4 = LabelNode('Game Over',color=('#0016ff'))
        self.card4.position = (300,460)
        self.add_child(self.card4)
        self.card4.size = (160,160)


        #pause symbol
        self.pause_button = SpriteNode('iow:pause_32', position=(32, self.size.h-32), parent=self)

    #control pause symbol button
    def touch_ended(self, touch):
        if self.pause_button.frame.contains_point(touch.location):
            self.v = ui.load_view('pawz.pyui')
            self.v['button1'].action = self.pawz_button_action
            self.v.present('sheet')
            self.v['textfield1'].begin_editing()

    def pawz_button_action(self,sender):

        self.v.close()

if __name__ == '__main__':
    run(Game(), PORTRAIT, show_fps=True)
sodoku

Something like if the text in the TextField equals the text in the label node add an emoji behind without deleting the words almost like a highlighting effect

cvp

@sodoku try this


from scene import *

class Game (Scene):
    def setup(self):
        self.background_color = '#004f82'
        ground = Node(parent=self)
        x = 0
        while x <= self.size.w + 64:
            tile = SpriteNode('plf:Ground_PlanetHalf_mid', position=(x, 0))
            ground.add_child(tile)
            x += 64
        self.player = SpriteNode('plf:AlienGreen_front')
        self.player.anchor_point = (0.5, 0)
        self.player.position = (self.size.w/2, 32)
        self.add_child(self.player)

        #Labels
        self.cards = []
        y = 760
        for l in ['Level 1','Level 2','Level 1','Game Over']:
            card = LabelNode(' ')#,color=('#0016ff'))
            card.font = ('Menlo',60)
            card.position = (300,y)
            card.size = (160,100)
            self.add_child(card)
            card_name = LabelNode(l)
            card_name.font = card.font
            card_name.size = card.size
            card.add_child(card_name)
            self.cards.append(card)
            y = y - 100

        #pause symbol
        self.pause_button = SpriteNode('iow:pause_32', position=(32, self.size.h-32), parent=self)

    #control pause symbol button
    def touch_ended(self, touch):
        if self.pause_button.frame.contains_point(touch.location):
            self.v = ui.load_view('pawz.pyui')
            self.v['button1'].action = self.pawz_button_action
            self.v.present('sheet')
            self.v['textfield1'].begin_editing()

    def pawz_button_action(self,sender):
        txt = self.v['textfield1'].text
        for card in self.cards:
            if card.children[0].text == txt:
                card.text = '😀'
        self.v.close()

if __name__ == '__main__':
    run(Game(), PORTRAIT, show_fps=True)

sodoku

also Would I be able to add an undo button beside the pause button at the top of the scene screen thanks for the help

sodoku

@cvp also Would I be able to add an undo button beside the pause button at the top of the scene screen thanks for the help

cvp

@sodoku Ok, I'm back. I assume you are able to add the button2 in the UI designer.
What do you call "undo"'? Just remove the emoji of the previous labels?

sodoku

I’ve add an undo and redo symbols in the code

from scene import *

class Game (Scene):
def setup(self):
self.background_color = '#004f82'
ground = Node(parent=self)
x = 0
while x <= self.size.w + 64:
tile = SpriteNode('plf:Ground_PlanetHalf_mid', position=(x, 0))
ground.add_child(tile)
x += 64
self.player = SpriteNode('plf:AlienGreen_front')
self.player.anchor_point = (0.5, 0)
self.player.position = (self.size.w/2, 32)
self.add_child(self.player)

    #Labels
    self.cards = []
    y = 760
    for l in ['Level 1','Level 2','Level 1','Game Over']:
        card = LabelNode(' ')#,color=('#0016ff'))
        card.font = ('Menlo',60)
        card.position = (300,y)
        card.size = (160,100)
        self.add_child(card)
        card_name = LabelNode(l)
        card_name.font = card.font
        card_name.size = card.size
        card.add_child(card_name)
        self.cards.append(card)
        y = y - 100

    #pause symbol
    self.pause_button = SpriteNode('iow:pause_32', position=(32, self.size.h-32), parent=self)

    #undo symbol
    self.undo_button = SpriteNode('iow:reply_256', position=(90, self.size.h-31), parent=self)
    self.undo_button.size = (50,50)

    #redo symbol
    self.redo_button = SpriteNode('iow:refresh_24', position=(160, self.size.h-31), parent=self)
    self.redo_button.size = (50,50)


#control pause symbol button
def touch_ended(self, touch):
    if self.pause_button.frame.contains_point(touch.location):
        self.v = ui.load_view('pawz.pyui')
        self.v['button1'].action = self.pawz_button_action
        self.v.present('sheet')
        self.v['textfield1'].begin_editing()

def pawz_button_action(self,sender):
    txt = self.v['textfield1'].text
    for card in self.cards:
        if card.children[0].text == txt:
            card.text = '😀'
    self.v.close()

if name == 'main':
run(Game(), PORTRAIT, show_fps=True)

cvp

@sodoku ok, I see but which process do you want to undo or redo?

sodoku

After I’ve added an emoji with the button inside the pause menu then I would like to undo add emoji and then redo add emoji Incase I’ve made mistakes

cvp

@sodoku do you want multiple successive undo or only the last one?

sodoku

Just the last one should do the trick

cvp

@sodoku Sorry, but while I was waiting for your answer, I wrote this code, supporting successive undo/redo

from scene import *

class Game (Scene):
    def setup(self):
        self.background_color = '#004f82'
        ground = Node(parent=self)
        x = 0
        while x <= self.size.w + 64:
            tile = SpriteNode('plf:Ground_PlanetHalf_mid', position=(x, 0))
            ground.add_child(tile)
            x += 64
        self.player = SpriteNode('plf:AlienGreen_front')
        self.player.anchor_point = (0.5, 0)
        self.player.position = (self.size.w/2, 32)
        self.add_child(self.player)

        #Labels
        self.evol = []
        self.cards = []
        y = 760
        evol = []
        for l in ['Level 1','Level 2','Level 1','Game Over']:
            card = LabelNode(' ')#,color=('#0016ff'))
            card.font = ('Menlo',60)
            card.position = (300,y)
            card.size = (160,100)
            self.add_child(card)
            card_name = LabelNode(l)
            card_name.font = card.font
            card_name.size = card.size
            card.add_child(card_name)
            self.cards.append(card)
            evol.append((l,card.text))
            y = y - 100
        self.evol.append(evol)
        self.current_evol = 0

        #pause symbol
        self.pause_button = SpriteNode('iow:pause_32', position=(32, self.size.h-32), parent=self)

        #undo symbol
        self.undo_button = SpriteNode('iow:reply_256', position=(90, self.size.h-31), parent=self)
        self.undo_button.size = (50,50)

        #redo symbol
        self.redo_button = SpriteNode('iow:refresh_24', position=(160, self.size.h-31), parent=self)
        self.redo_button.size = (50,50)

    #control pause symbol button
    def touch_ended(self, touch):
        if self.pause_button.frame.contains_point(touch.location):
            self.v = ui.load_view('pawz.pyui')
            self.v['button1'].action = self.pawz_button_action
            self.v.present('sheet')
            self.v['textfield1'].begin_editing()
        elif self.undo_button.frame.contains_point(touch.location):
            if self.current_evol > 0:
                self.current_evol -= 1
                evol = self.evol[self.current_evol]
                #print('undo',self.current_evol,evol)
                for e in evol:
                    txt = e[0]
                    for card in self.cards:
                        if card.children[0].text == txt:
                            card.text = e[1]
        elif self.redo_button.frame.contains_point(touch.location):
            if self.current_evol < (len(self.evol)-1):
                self.current_evol += 1
                evol = self.evol[self.current_evol]
                #print('redo',self.current_evol,evol)
                for e in evol:
                    txt = e[0]
                    for card in self.cards:
                        if card.children[0].text == txt:
                            card.text = e[1]

    def pawz_button_action(self,sender):
        # pause button
        txt = self.v['textfield1'].text
        evol = []
        for card in self.cards:
            if card.children[0].text == txt:
                card.text = '😀'
            else:
                card.text = ' '
            evol.append((card.children[0].text,card.text))
        self.evol.append(evol)
        self.current_evol = len(self.evol) - 1
        self.v.close()


if __name__ == '__main__':
    run(Game(), PORTRAIT, show_fps=True)

sodoku

@cvp
Awesome logic skills dude thanks I’m learning a lot from you

sodoku

@cvp is it possible not to erase the emoji when you add more then one
For example if I add emojis to Level 1 then if I add an emoji to Game Over without deleting the Level 1 emojis so all three are covered??or all four can be covered
This aspect worked in the previous version you coded before the undo redo upgrade

cvp

@sodoku yes, of course, sorry. Two lines to comment

    def pawz_button_action(self,sender):
        # pause button
        txt = self.v['textfield1'].text
        evol = []
        for card in self.cards:
            if card.children[0].text == txt:
                card.text = '😀'
            #else:
            #   card.text = ' '
            evol.append((card.children[0].text,card.text))
        self.evol.append(evol)
        self.current_evol = len(self.evol) - 1
        self.v.close() 
sodoku

Wow fantastic, your truly amazing I can’t thank you enough

sodoku

Help me again please
Okay the pawz.pyui only has one TextField and one button

So what I need help with is, I wanted to be able to is input the emoji into scene A and scene B without having to manually go to each scene and adding the emoji twice

So the objective is, if I add the emoji behind the text in scene B it would be automatically added behind the text in scene A and vice versa if I add the emoji behind the text in scene A it would automatically be added behind the text in scene B

from scene import *
import ui
#import time
import scene
import console


class MainMenuScene (Scene):
    def setup(self):
        self.background = SpriteNode(color = 'blue')
        self.background.size = self.size
        self.background.position = self.size / 2
        self.add_child(self.background)

        self.page1=LabelNode('page1')
        self.page1.size=(75,75)
        self.page1.position=(44,860)
        self.add_child(self.page1)

        self.page2=LabelNode('page2')
        self.page2.size=(75,75)
        self.page2.position=(44,760)
        self.add_child(self.page2)

    def touch_began(self, touch):
        if self.page1.frame.contains_point(touch.location):
            self.present_modal_scene(a_scene)

        elif self.page2.frame.contains_point(touch.location):
            self.present_modal_scene(b_scene)


#class Game (Scene):
class AScene (Scene):
    def setup(self):

        self.background = SpriteNode(color = 'red')
        self.background.size = self.size
        self.background.position = self.size / 2
        self.add_child(self.background)

        self.main=LabelNode('main')
        self.main.size=(75,75)
        self.main.position=(44,860)
        self.add_child(self.main)

        self.background_color = '#004f82'
        ground = Node(parent=self)
        x = 0
        while x <= self.size.w + 64:
            tile = SpriteNode('plf:Ground_PlanetHalf_mid', position=(x, 0))
            ground.add_child(tile)
            x += 64
        self.player = SpriteNode('plf:AlienGreen_front')
        self.player.anchor_point = (0.5, 0)
        self.player.position = (self.size.w/2, 32)
        self.add_child(self.player)

        #Labels
        self.evol = []
        self.cards = []
        y = 760
        evol = []
        for l in ['Level 1','Level 2','Level 1','Game Over']:
            card = LabelNode(' ')#,color=('#0016ff'))
            card.font = ('Menlo',60)
            card.position = (300,y)
            card.size = (160,100)
            self.add_child(card)
            card_name = LabelNode(l)
            card_name.font = card.font
            card_name.size = card.size
            card.add_child(card_name)
            self.cards.append(card)
            evol.append((l,card.text))
            y = y - 100
        self.evol.append(evol)
        self.current_evol = 0

        #pause symbol
        self.pause_button = SpriteNode('iow:pause_32', position=(32, self.size.h-32), parent=self)

        #undo symbol
        self.undo_button = SpriteNode('iow:reply_256', position=(90, self.size.h-31), parent=self)
        self.undo_button.size = (50,50)

        #redo symbol
        self.redo_button = SpriteNode('iow:refresh_24', position=(160, self.size.h-31), parent=self)
        self.redo_button.size = (50,50)

    #control pause symbol button
    def touch_ended(self, touch):
        if self.pause_button.frame.contains_point(touch.location):
            self.v = ui.load_view('pawz.pyui')
            self.v['button1'].action = self.pawz_button_action
            self.v.present('sheet')
            self.v['textfield1'].begin_editing()
        elif self.undo_button.frame.contains_point(touch.location):
            if self.current_evol > 0:
                self.current_evol -= 1
                evol = self.evol[self.current_evol]
                #print('undo',self.current_evol,evol)
                for e in evol:
                    txt = e[0]
                    for card in self.cards:
                        if card.children[0].text == txt:
                            card.text = e[1]
        elif self.redo_button.frame.contains_point(touch.location):
            if self.current_evol < (len(self.evol)-1):
                self.current_evol += 1
                evol = self.evol[self.current_evol]
                #print('redo',self.current_evol,evol)
                for e in evol:
                    txt = e[0]
                    for card in self.cards:
                        if card.children[0].text == txt:
                            card.text = e[1]

    def pawz_button_action(self,sender):
        # pause button
        txt = self.v['textfield1'].text
        evol = []
        for card in self.cards:
            if card.children[0].text == txt:
                card.text = '😀'
            #else:
                #card.text = ' '
            evol.append((card.children[0].text,card.text))
        self.evol.append(evol)
        self.current_evol = len(self.evol) - 1
        self.v.close()


    def touch_began(self, touch):
        if self.main.frame.contains_point(touch.location):
            self.dismiss_modal_scene()

class BScene (Scene):
    def setup(self):

        self.background = SpriteNode(color = '#71edff')
        self.background.size = self.size
        self.background.position = self.size / 2
        self.add_child(self.background)

        self.main=LabelNode('main')
        self.main.size=(75,75)
        self.main.position=(44,760)
        self.add_child(self.main)

        self.background_color = '#004f82'
        ground = Node(parent=self)
        x = 0
        while x <= self.size.w + 64:
            tile = SpriteNode('plf:Ground_PlanetHalf_mid', position=(x, 0))
            ground.add_child(tile)
            x += 64
        self.player = SpriteNode('plf:AlienGreen_front')
        self.player.anchor_point = (0.5, 0)
        self.player.position = (self.size.w/2, 32)
        self.add_child(self.player)

        #Labels
        self.evol = []
        self.cards = []
        y = 760
        evol = []
        for l in ['Level 1','Level 2','Level 1','Game Over']:
            card = LabelNode(' ')#,color=('#0016ff'))
            card.font = ('Menlo',60)
            card.position = (300,y)
            card.size = (160,100)
            self.add_child(card)
            card_name = LabelNode(l)
            card_name.font = card.font
            card_name.size = card.size
            card.add_child(card_name)
            self.cards.append(card)
            evol.append((l,card.text))
            y = y - 100
        self.evol.append(evol)
        self.current_evol = 0

        #pause symbol
        self.pause_button = SpriteNode('iow:pause_32', position=(32, self.size.h-32), parent=self)

        #undo symbol
        self.undo_button = SpriteNode('iow:reply_256', position=(90, self.size.h-31), parent=self)
        self.undo_button.size = (50,50)

        #redo symbol
        self.redo_button = SpriteNode('iow:refresh_24', position=(160, self.size.h-31), parent=self)
        self.redo_button.size = (50,50)

    #control pause symbol button
    def touch_ended(self, touch):
        if self.pause_button.frame.contains_point(touch.location):
            self.v = ui.load_view('pawz.pyui')
            self.v['button1'].action = self.pawz_button_action
            self.v.present('sheet')
            self.v['textfield1'].begin_editing()
        elif self.undo_button.frame.contains_point(touch.location):
            if self.current_evol > 0:
                self.current_evol -= 1
                evol = self.evol[self.current_evol]
                #print('undo',self.current_evol,evol)
                for e in evol:
                    txt = e[0]
                    for card in self.cards:
                        if card.children[0].text == txt:
                            card.text = e[1]
        elif self.redo_button.frame.contains_point(touch.location):
            if self.current_evol < (len(self.evol)-1):
                self.current_evol += 1
                evol = self.evol[self.current_evol]
                #print('redo',self.current_evol,evol)
                for e in evol:
                    txt = e[0]
                    for card in self.cards:
                        if card.children[0].text == txt:
                            card.text = e[1]

    def pawz_button_action(self,sender):
        # pause button
        txt = self.v['textfield1'].text
        evol = []
        for card in self.cards:
            if card.children[0].text == txt:
                card.text = '😀'
            #else:
                #card.text = ' '
            evol.append((card.children[0].text,card.text))
        self.evol.append(evol)
        self.current_evol = len(self.evol) - 1
        self.v.close()


    def touch_began(self, touch):
        if self.main.frame.contains_point(touch.location):
            self.dismiss_modal_scene()


main_menu_scene = MainMenuScene()
a_scene = AScene()
b_scene = BScene()

main_view = ui.View()
scene_view = SceneView(frame=main_view.bounds, flex='WH')
main_view.add_subview(scene_view)
scene_view.scene = main_menu_scene
main_view.present(hide_title_bar=True, animated=False)
cvp

@sodoku first, t o be able to help you, we need your script correctly indented by putting
3 back ticks above and bottom ```
You have used bad apostrophes

sodoku

Help me again I fixed the 3 ticks thing in the post above

cvp

@sodoku I've copied your script in my Pythonista and created a pawn.pyui with a button and a TextField.
This is presented when I tap pause but I really don't understand your request.
Where do you want to store/show the text you type in the TextField?

sodoku

The pyui is called pawz not pawn

sodoku

So when you type Game Over or Level 1 in the text field in either scenes pawz menu it adds the emojis to scene A and scene B simultaneously

cvp

@sodoku yes, pawz, autocorrect 😢

But where this text has to be added?

sodoku

I don’t understand your question I just wanted to add the emoji behind the label node text by typing the label node text into the text field
It works as is but I need to tap page1 then tap the pawz menu type the label node text to add the emojis then I have to tap main to go back to the first scene and then tap page2 then tap pawz then type the label node text again in order to get both pages (scenes a and b) to display the emojis
I just would like to only have to tap pawz once and type the label node text once so the emojis get added to both pages (scene a and b)

cvp

@sodoku ok, I think I understand, please wait a little bit

cvp

@sodoku sorry for the delay, busy...
This works but very dirty, a little bit obliged by the way you define two scenes without passing by an unic class.

touch_began of class MainMenuScene (Scene)

After presentation of a page, init texts of cards with texts of other page...

    def touch_began(self, touch):
        if self.page1.frame.contains_point(touch.location):
            self.present_modal_scene(a_scene)
            for child1 in a_scene.children:
              if len(child1.children) > 0:
                if 'LabelNode' in str(type(child1.children[0])):
                  lvl = child1.children[0].text
                  for child2 in b_scene.children:
                    if len(child2.children) > 0:
                      if 'LabelNode' in str(type(child2.children[0])):
                        if child2.children[0].text == lvl:
                          child1.text = child2.text
        elif self.page2.frame.contains_point(touch.location):
            self.present_modal_scene(b_scene)
            for child1 in b_scene.children:
              if len(child1.children) > 0:
                if 'LabelNode' in str(type(child1.children[0])):
                  lvl = child1.children[0].text
                  for child2 in a_scene.children:
                    if len(child2.children) > 0:
                      if 'LabelNode' in str(type(child2.children[0])):
                        if child2.children[0].text == lvl:
                          child1.text = child2.text 
sodoku

I think that solves my question thank you @cvp that will be the finishing touch to my first prototype app I’m developing I just need to buy a iPhone so I can add text recognition to my sudoku app

cvp

@sodoku good luck with your project

ccc

if 'LabelNode' in str(type(child2.children[0])) -->
if isinstance(child2.children[0], LabelNode) ??

cvp

@ccc I knew it, you have already adviced me, but I had forgotten 😢

sodoku

Did @ccc add a suggestion to improve the coding that @cvp suggested just asking because I know how to add @cvp’s idea to my module I just don’t know where to add the code suggested by @ccc to my module

ccc

Stick with @cvp code that works.

sodoku

I don’t know if my next question I got for you can be solved, okay so I have added @cvp’s code to mine and it works perfectly, except for the undo and redo functions have now become a little glitchy (not working perfectly), I was wondering if it’s possible to fix this or not??

stephen

@ccc @cvp

i have no idea whats going on here 😂 but since we are dealing with two separate instances of scene could giving time by Action.wait(0.5)(some arbitrary value) or even time.sleep(0.5) to inssure processes have time to sync? to help the new found "glitching"?

just a guess im only recently getting into threads and processes..

sodoku

The only work around I can think of is limiting only page 1 to have the add emoji input, and undo, and redo while removing those three actions from page 2 to kinda make it idiot/fool proof so the functions undo and redo doesn’t glitch, and users won’t get confused and ruin the order of operations
So basically add emoji, undo and redo would only be available on page 1 and then page 2 would just be a viewable screen to observe then you would have to go back to page 1 to add, undo or redo

Except that would kinda hinder the game play by adding to much unnecessary steps to manually back track, and it would ruin the experience and point of being an app that saves time

I hope this could be fixed that would make this app seem more professional

stephen

@sodoku if we are dealing with paging.. why not get rid of buttons, and use gestures? should fix current issue and increase time saved for user?

sodoku

The thing is i understand the problem I’m encountering, and the main objective and goal I want to achieve, I just have no clue how to code the solution or if it’s even possible to code a solution, at this level of of coding it’s to easy to make a mistake and not code the proper order of operations

I just know how to ask the smarter people the question, is it possible to fix this problem

stephen

@sodoku

i know you guys are already this far and i hate to ask people to repeat themselves but im really interested in this situation. if you dont mind can you elaborate on the program and issue?

cvp

@stephen said:

if we are dealing with paging.. why not get rid of buttons, and use gestures? should fix current issue and increase time saved for user?

It is sure you are right but @sodoku wants to go on with his code that he understands, thus...

First, I'll try to solve his problem of undo

cvp

@sodoku still dirt and unprofessional, but works for one undo/redo cross pages, but not for successive undo/redo

from scene import *
import ui
#import time
import scene
import console

gen_evol = []
gen_current_evol = 0

class MainMenuScene (Scene):
    def setup(self):
        self.background = SpriteNode(color = 'blue')
        self.background.size = self.size
        self.background.position = self.size / 2
        self.add_child(self.background)

        self.page1=LabelNode('page1')
        self.page1.size=(75,75)
        self.page1.position=(44,860)
        self.add_child(self.page1)

        self.page2=LabelNode('page2')
        self.page2.size=(75,75)
        self.page2.position=(44,760)
        self.add_child(self.page2)

    def touch_began(self, touch):
        if self.page1.frame.contains_point(touch.location):
            self.present_modal_scene(a_scene)
            for child1 in a_scene.children:
              if len(child1.children) > 0:
                if isinstance(child1.children[0], LabelNode):
                  lvl = child1.children[0].text
                  for child2 in b_scene.children:
                    if len(child2.children) > 0:
                      if isinstance(child2.children[0], LabelNode):
                        if child2.children[0].text == lvl:
                          child1.text = child2.text
        elif self.page2.frame.contains_point(touch.location):
            self.present_modal_scene(b_scene)
            for child1 in b_scene.children:
              if len(child1.children) > 0:
                if isinstance(child1.children[0], LabelNode):
                  lvl = child1.children[0].text
                  for child2 in a_scene.children:
                    if len(child2.children) > 0:
                      if isinstance(child2.children[0], LabelNode):
                        if child2.children[0].text == lvl:
                          child1.text = child2.text 

#class Game (Scene):
class AScene (Scene):
    def setup(self):
        global gen_evol,gen_current_evol
        self.background = SpriteNode(color = 'red')
        self.background.size = self.size
        self.background.position = self.size / 2
        self.add_child(self.background)

        self.main=LabelNode('main')
        self.main.size=(75,75)
        self.main.position=(44,860)
        self.add_child(self.main)

        self.background_color = '#004f82'
        ground = Node(parent=self)
        x = 0
        while x <= self.size.w + 64:
            tile = SpriteNode('plf:Ground_PlanetHalf_mid', position=(x, 0))
            ground.add_child(tile)
            x += 64
        self.player = SpriteNode('plf:AlienGreen_front')
        self.player.anchor_point = (0.5, 0)
        self.player.position = (self.size.w/2, 32)
        self.add_child(self.player)

        #Labels
        gen_evol = []
        self.cards = []
        y = 760
        evol = []
        for l in ['Level 1','Level 2','Level 1','Game Over']:
            card = LabelNode(' ')#,color=('#0016ff'))
            card.font = ('Menlo',60)
            card.position = (300,y)
            card.size = (160,100)
            self.add_child(card)
            card_name = LabelNode(l)
            card_name.font = card.font
            card_name.size = card.size
            card.add_child(card_name)
            self.cards.append(card)
            evol.append((l,card.text))
            y = y - 100
        gen_evol.append(evol)
        gen_current_evol = 0

        #pause symbol
        self.pause_button = SpriteNode('iow:pause_32', position=(32, self.size.h-32), parent=self)

        #undo symbol
        self.undo_button = SpriteNode('iow:reply_256', position=(90, self.size.h-31), parent=self)
        self.undo_button.size = (50,50)

        #redo symbol
        self.redo_button = SpriteNode('iow:refresh_24', position=(160, self.size.h-31), parent=self)
        self.redo_button.size = (50,50)

    #control pause symbol button
    def touch_ended(self, touch):
        global gen_evol,gen_current_evol
        if self.pause_button.frame.contains_point(touch.location):
            self.v = ui.load_view('pawz.pyui')
            self.v['button1'].action = self.pawz_button_action
            self.v.present('sheet')
            self.v['textfield1'].begin_editing()
        elif self.undo_button.frame.contains_point(touch.location):
            if gen_current_evol > 0:
                gen_current_evol -= 1
                evol = gen_evol[gen_current_evol]
                #print('undo',gen_current_evol,evol)
                for e in evol:
                    txt = e[0]
                    for card in self.cards:
                        if card.children[0].text == txt:
                            card.text = e[1]
        elif self.redo_button.frame.contains_point(touch.location):
            if gen_current_evol < (len(gen_evol)-1):
                gen_current_evol += 1
                evol = gen_evol[gen_current_evol]
                #print('redo',gen_current_evol,evol)
                for e in evol:
                    txt = e[0]
                    for card in self.cards:
                        if card.children[0].text == txt:
                            card.text = e[1]

    def pawz_button_action(self,sender):
        global gen_evol,gen_current_evol
        # pause button
        txt = self.v['textfield1'].text
        evol = []
        for card in self.cards:
            if card.children[0].text == txt:
                card.text = '😀'
            #else:
                #card.text = ' '
            evol.append((card.children[0].text,card.text))
        gen_evol.append(evol)
        gen_current_evol = len(gen_evol) - 1
        self.v.close()


    def touch_began(self, touch):
        if self.main.frame.contains_point(touch.location):
            self.dismiss_modal_scene()

class BScene (Scene):
    def setup(self):
        global gen_evol,gen_current_evol
        self.background = SpriteNode(color = '#71edff')
        self.background.size = self.size
        self.background.position = self.size / 2
        self.add_child(self.background)

        self.main=LabelNode('main')
        self.main.size=(75,75)
        self.main.position=(44,760)
        self.add_child(self.main)

        self.background_color = '#004f82'
        ground = Node(parent=self)
        x = 0
        while x <= self.size.w + 64:
            tile = SpriteNode('plf:Ground_PlanetHalf_mid', position=(x, 0))
            ground.add_child(tile)
            x += 64
        self.player = SpriteNode('plf:AlienGreen_front')
        self.player.anchor_point = (0.5, 0)
        self.player.position = (self.size.w/2, 32)
        self.add_child(self.player)

        #Labels
        gen_evol = []
        self.cards = []
        y = 760
        evol = []
        for l in ['Level 1','Level 2','Level 1','Game Over']:
            card = LabelNode(' ')#,color=('#0016ff'))
            card.font = ('Menlo',60)
            card.position = (300,y)
            card.size = (160,100)
            self.add_child(card)
            card_name = LabelNode(l)
            card_name.font = card.font
            card_name.size = card.size
            card.add_child(card_name)
            self.cards.append(card)
            evol.append((l,card.text))
            y = y - 100
        gen_evol.append(evol)
        gen_current_evol = 0

        #pause symbol
        self.pause_button = SpriteNode('iow:pause_32', position=(32, self.size.h-32), parent=self)

        #undo symbol
        self.undo_button = SpriteNode('iow:reply_256', position=(90, self.size.h-31), parent=self)
        self.undo_button.size = (50,50)

        #redo symbol
        self.redo_button = SpriteNode('iow:refresh_24', position=(160, self.size.h-31), parent=self)
        self.redo_button.size = (50,50)

    #control pause symbol button
    def touch_ended(self, touch):
        global gen_evol,gen_current_evol
        if self.pause_button.frame.contains_point(touch.location):
            self.v = ui.load_view('pawz.pyui')
            self.v['button1'].action = self.pawz_button_action
            self.v.present('sheet')
            self.v['textfield1'].begin_editing()
        elif self.undo_button.frame.contains_point(touch.location):
            if gen_current_evol > 0:
                gen_current_evol -= 1
                evol = gen_evol[gen_current_evol]
                #print('undo',gen_current_evol,evol)
                for e in evol:
                    txt = e[0]
                    for card in self.cards:
                        if card.children[0].text == txt:
                            card.text = e[1]
        elif self.redo_button.frame.contains_point(touch.location):
            if gen_current_evol < (len(gen_evol)-1):
                gen_current_evol += 1
                evol = gen_evol[gen_current_evol]
                #print('redo',gen_current_evol,evol)
                for e in evol:
                    txt = e[0]
                    for card in self.cards:
                        if card.children[0].text == txt:
                            card.text = e[1]

    def pawz_button_action(self,sender):
        global gen_evol,gen_current_evol
        # pause button
        txt = self.v['textfield1'].text
        evol = []
        for card in self.cards:
            if card.children[0].text == txt:
                card.text = '😀'
            #else:
                #card.text = ' '
            evol.append((card.children[0].text,card.text))
        gen_evol.append(evol)
        gen_current_evol = len(gen_evol) - 1
        self.v.close()


    def touch_began(self, touch):
        if self.main.frame.contains_point(touch.location):
            self.dismiss_modal_scene()


main_menu_scene = MainMenuScene()
a_scene = AScene()
b_scene = BScene()

main_view = ui.View()
scene_view = SceneView(frame=main_view.bounds, flex='WH')
main_view.add_subview(scene_view)
scene_view.scene = main_menu_scene
main_view.present(hide_title_bar=True, animated=False)