如何通过Python点击显示图像
你好,我有一个我正在制作的东西,每次你点击屏幕,就会弹出一个新的gif。然而,当我运行它时,当我单击时,新屏幕上什么也没有显示。
这就是我到目前为止所拥有的
选择 | 换行 | 行号
- import glob
- ypos = 0
- xpos = 0
- robotArmy = []
- def setup():
- global ypos
- size(700,700)
- ypos = height * 0.25
- frameRate(12)
- global animation1
- animation1 = robots("./RobotGIF/robotprojects-",15) #ref from animatedspriteclass
- def draw():
- background(255)
- class robots:
- def __init__(self,imagePrefix,c): #from animatedSpriteClass
- self.imageCount = c
- self.images = []
- self.frame = 0
- print self.imageCount
- for i in range(self.imageCount):
- filename = imagePrefix + nf(i, 4) + ".gif"
- self.images.append( loadImage(filename) )
- def draw(self,x,y): #ref animatedspriteclass
- self.frame = (self.frame+1) % self.imageCount
- image(self.images[self.frame], x, y)
- def getWidth(self):
- return self.images[0].width
- def mousePressed():
- robotArmy.append(animation1)