Изображение остается видимым на холсте, несмотря на то, что оно скрыто - PullRequest
0 голосов
/ 10 марта 2019

Я создаю игру для школы.У меня большая часть игры работает без магазина.Тем не менее, в первый раз, когда вы «убиваете» врага, нажав несколько раз кнопку атаки, он все нормально возродится и вернется на экран, но когда вы убьете его, его «пустой» кадр останется видимым во время воспроизведения анимации смерти.,Я много просмотрел свой код и не могу понять почему.Код игры слишком велик, чтобы скопировать сюда, но вот часть, которая делает это.По сути, вы нажимаете атаку, и как только количество жизней достигает 0, запускается анимация смерти и получает новое значение жизни, основанное на материале, который вы купили в магазине.

def coinUp():
    global coins
    global coinsCounter
    coins = coins + coinIncrease
    fightScreen.delete(coinsCounter)
    coinsCounter = fightScreen.create_text(210, 30, text = coins, font = ("calibri", 35), fill = ("gold"))

def enemyHealth():
    global healthCounter
    global eneLives
    eneLives = eneLives - attackPower
    if eneLives >= 1:
        fightScreen.delete(healthCounter)
        healthCounter = fightScreen.create_text(595, 30, text = eneLives, font = ("calibri", 35), fill = ("red"))
    elif eneLives <= 0:
        fightScreen.delete(healthCounter)
        fightScreen.itemconfig(enemyIdle, state = HIDDEN)
        enemyDie()
        time.sleep(2)
        enemyWalk()

def eneHealthDecider():
        global healthCounter
        global eneLives
        eneLives = coinIncrease*attackPower
        if eneLives % 2 != 0:
            eneLives = eneLives + 1
        healthCounter = fightScreen.create_text(595, 30, text = eneLives, font = ("calibri", 35), fill = ("red"))

coinsText = fightScreen.create_text(100, 30, text = "Coins:", font = ("calibri", 35), fill = ("gold"))
coinsCounter = fightScreen.create_text(210, 30, text = coins, font = ("calibri", 35), fill = ("gold"))
healthCounter = fightScreen.create_text(595, 30, text = eneLives, font = ("calibri", 35), fill = ("red"))
healthText = fightScreen.create_text(470, 30, text = "Health:", font = ("calibri", 35), fill = ("red"))    
attack = fightScreen.create_window(170, 380, window = Button(fightScreen, text = "Attack!", font = ("calibri" , 20), command = shoot))
openShop = fightScreen.create_window(80, 380, window = Button(fightScreen, text = "Shop", font = ("calibri" , 20), command = shop))

mainloop()
...