0
Pythonで目を動かすにはどうすればいいですか?私は左の動きを定義したときにc.move(eye、-10、0)を試しました。私は目に隠された状態も試してみましたが、通常の状態でleft_eyeを作成しましたが、うまくいきません。 ありがとうございます。tkinter - 形を移動する
from tkinter import *
HEIGHT = 500
WIDTH = 800
window = Tk()
window.title('Fetita arunca mingea')
c = Canvas (window, width = WIDTH, height = HEIGHT, bg = 'grey')
c.pack()
school= c.create_rectangle (200, 50,600, 150, fill = 'orange')
school_window1 = c.create_rectangle (250,80, 300, 100, fill= 'yellow')
school_window2 = c.create_rectangle (360,80, 420, 100, fill= 'yellow')
school_window2 = c.create_rectangle (500,80, 550, 100, fill= 'yellow')
body =c.create_polygon (0, 450, 250, 450, 100, 240,fill ='blue')
head = c.create_oval (50, 250, 150, 150, fill = 'ivory')
eye =c.create_oval (120 ,180, 125, 185,fill ='blue')
#eye_left =c.create_oval (75 ,180, 80, 185,fill ='yellow')
eye_left = c.move(eye,-10,0)
mouth = c.create_line (145, 220, 120, 220,fill = 'red')
#mouth_left = c.create_line (55, 220, 80, 220,fill = 'blue')
hand =c.create_line (110, 300, 200, 220, fill = 'black')
GIRL_step = 10
def move_girl(event):
if event.keysym == 'Up':
c.move (body, 0, - GIRL_step)
c.move (head, 0, - GIRL_step)
c.move (eye, 0, - GIRL_step)
c.move (mouth, 0, - GIRL_step)
c.move (hand, 0, - GIRL_step)
elif event.keysym== 'Down':
c.move (body, 0, GIRL_step)
c.move (head, 0, GIRL_step)
c.move (eye, 0, GIRL_step)
c.move (mouth, 0, GIRL_step)
c.move (hand, 0, GIRL_step)
elif event.keysym== 'Left':
c.move(eye,-10, 0)
c.move (body, - GIRL_step, 0)
c.move (head, - GIRL_step, 0)
c.move (eye, - GIRL_step, 0)
c.move (mouth, _GIRL_step, 0)
c.move (hand, - GIRL_step, 0)
elif event.keysym== 'Right':
c.move (body, GIRL_step, 0)
c.move (head, GIRL_step, 0)
c.move (eye, GIRL_step, 0)
c.move (mouth, GIRL_step, 0)
c.move (hand, GIRL_step, 0)
c.bind_all ('<Key>', move_girl)
次の例を排除する機能が原因タイプ(下線で動作しないために()を使用することができます移動の目のマイナス記号の代わりに "左")。タイプミスを修正した後で動作します。さらに、顔の動きをテストする必要があります。目は、左に動くための頭のx-半径よりも小さくなります。 –